From: Hypolite Petovan Date: Sun, 17 Dec 2017 20:24:57 +0000 (-0500) Subject: PHPStan: Fix missing requires/namespaces X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=10b72b0e9eb0aa2ef1f2c612464ffcbbe4cc02ce;p=friendica.git PHPStan: Fix missing requires/namespaces --- diff --git a/src/App.php b/src/App.php index 3e34d3c5a9..adea01a037 100644 --- a/src/App.php +++ b/src/App.php @@ -14,6 +14,9 @@ use Detection\MobileDetect; use Exception; +require_once 'boot.php'; +require_once 'include/dba.php'; + /** * * class: App diff --git a/src/Content/ForumManager.php b/src/Content/ForumManager.php index d619db42b2..d800a0bd8b 100644 --- a/src/Content/ForumManager.php +++ b/src/Content/ForumManager.php @@ -11,6 +11,8 @@ use Friendica\Core\System; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + /** * @brief This class handles methods related to the forum functionality */ diff --git a/src/Core/Cache.php b/src/Core/Cache.php index eb58811e2c..4da097ce2a 100644 --- a/src/Core/Cache.php +++ b/src/Core/Cache.php @@ -9,6 +9,8 @@ use Friendica\Core\PConfig; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + /** * @brief Class for storing data for a short time */ @@ -32,7 +34,7 @@ class Cache $memcache_host = Config::get('system', 'memcache_host', '127.0.0.1'); $memcache_port = Config::get('system', 'memcache_port', 11211); - $memcache = new Memcache; + $memcache = new \Memcache; if (!$memcache->connect($memcache_host, $memcache_port)) { return false; diff --git a/src/Core/Config.php b/src/Core/Config.php index d3daece159..2515116a9b 100644 --- a/src/Core/Config.php +++ b/src/Core/Config.php @@ -11,6 +11,8 @@ namespace Friendica\Core; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + /** * @brief Arbitrary sytem configuration storage * diff --git a/src/Core/NotificationsManager.php b/src/Core/NotificationsManager.php index 9adac10c92..7b9dba8963 100644 --- a/src/Core/NotificationsManager.php +++ b/src/Core/NotificationsManager.php @@ -6,11 +6,12 @@ */ namespace Friendica\Core; -use Friendica\Core\Pconfig; +use Friendica\Core\PConfig; use Friendica\Core\System; use Friendica\Database\DBM; use Friendica\Model\Contact; +require_once 'include/dba.php'; require_once 'include/html2plain.php'; require_once 'include/datetime.php'; require_once 'include/bbcode.php'; diff --git a/src/Core/PConfig.php b/src/Core/PConfig.php index 3467032fa2..bf84a4b8f7 100644 --- a/src/Core/PConfig.php +++ b/src/Core/PConfig.php @@ -7,6 +7,8 @@ namespace Friendica\Core; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + /** * @file include/Core/PConfig.php * @brief contains the class with methods for the management diff --git a/src/Core/Worker.php b/src/Core/Worker.php index 2e7bb483e8..760b40b1d3 100644 --- a/src/Core/Worker.php +++ b/src/Core/Worker.php @@ -13,6 +13,8 @@ use Friendica\Util\Lock; use dba; +require_once 'include/dba.php'; + /** * @file src/Core/Worker.php * diff --git a/src/Database/DBM.php b/src/Database/DBM.php index 7b52c0a552..e59249e1b9 100644 --- a/src/Database/DBM.php +++ b/src/Database/DBM.php @@ -6,6 +6,8 @@ namespace Friendica\Database; use dba; +require_once 'include/dba.php'; + /** * @brief This class contain functions for the database management * diff --git a/src/Database/DBStructure.php b/src/Database/DBStructure.php index 7a6c3eaa70..c5bd3e99bc 100644 --- a/src/Database/DBStructure.php +++ b/src/Database/DBStructure.php @@ -9,6 +9,8 @@ use Friendica\Database\DBM; use dba; require_once "boot.php"; +require_once 'include/dba.php'; +require_once 'include/enotify.php'; require_once "include/text.php"; /** @@ -565,7 +567,7 @@ class DBStructure { private static function createIndex($indexname, $fieldnames, $method = "ADD") { $method = strtoupper(trim($method)); if ($method!="" && $method!="ADD") { - throw new Exception("Invalid parameter 'method' in self::createIndex(): '$method'"); + throw new \Exception("Invalid parameter 'method' in self::createIndex(): '$method'"); } if ($fieldnames[0] == "UNIQUE") { diff --git a/src/Model/Contact.php b/src/Model/Contact.php index 2203b62162..aec417a65d 100644 --- a/src/Model/Contact.php +++ b/src/Model/Contact.php @@ -20,6 +20,7 @@ use Friendica\Protocol\Salmon; use dba; require_once 'boot.php'; +require_once 'include/dba.php'; require_once 'include/text.php'; /** diff --git a/src/Model/GContact.php b/src/Model/GContact.php index 1b846b3171..5622124481 100644 --- a/src/Model/GContact.php +++ b/src/Model/GContact.php @@ -17,6 +17,7 @@ use dba; use Exception; require_once 'include/datetime.php'; +require_once 'include/dba.php'; require_once 'include/network.php'; require_once 'include/html2bbcode.php'; diff --git a/src/Model/Group.php b/src/Model/Group.php index 9251bc49de..209c78798b 100644 --- a/src/Model/Group.php +++ b/src/Model/Group.php @@ -11,6 +11,7 @@ use Friendica\Database\DBM; use dba; require_once 'boot.php'; +require_once 'include/dba.php'; require_once 'include/text.php'; /** diff --git a/src/Model/Photo.php b/src/Model/Photo.php index 229f221077..0fbeb66cbb 100644 --- a/src/Model/Photo.php +++ b/src/Model/Photo.php @@ -12,7 +12,9 @@ use Friendica\Database\DBM; use Friendica\Object\Image; use dba; +require_once 'include/dba.php'; require_once "include/photos.php"; + /** * Class to handle photo dabatase table */ diff --git a/src/Model/User.php b/src/Model/User.php index d09d670a4b..9762727aca 100644 --- a/src/Model/User.php +++ b/src/Model/User.php @@ -21,6 +21,7 @@ use Exception; require_once 'boot.php'; require_once 'include/crypto.php'; +require_once 'include/dba.php'; require_once 'include/enotify.php'; require_once 'include/network.php'; require_once 'library/openid.php'; @@ -186,7 +187,7 @@ class User $_SESSION['register'] = 1; $_SESSION['openid'] = $openid_url; - $openid = new LightOpenID; + $openid = new \LightOpenID; $openid->identity = $openid_url; $openid->returnUrl = System::baseUrl() . '/openid'; $openid->required = array('namePerson/friendly', 'contact/email', 'namePerson'); diff --git a/src/Network/FKOAuthDataStore.php b/src/Network/FKOAuthDataStore.php index d7fa145189..e8f580c58a 100644 --- a/src/Network/FKOAuthDataStore.php +++ b/src/Network/FKOAuthDataStore.php @@ -17,6 +17,8 @@ use OAuthDataStore; define('REQUEST_TOKEN_DURATION', 300); define('ACCESS_TOKEN_DURATION', 31536000); +require_once 'include/dba.php'; + require_once "library/OAuth1.php"; require_once "library/oauth2-php/lib/OAuth2.inc"; @@ -45,7 +47,7 @@ class FKOAuthDataStore extends OAuthDataStore $r = dba::inArray($r); if (DBM::is_result($r)) { - return new OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']); + return new \OAuthConsumer($r[0]['client_id'], $r[0]['pw'], $r[0]['redirect_uri']); } return null; @@ -65,7 +67,7 @@ class FKOAuthDataStore extends OAuthDataStore $r = dba::inArray($s); if (DBM::is_result($r)) { - $ot=new OAuthToken($r[0]['id'], $r[0]['secret']); + $ot = new \OAuthToken($r[0]['id'], $r[0]['secret']); $ot->scope = $r[0]['scope']; $ot->expires = $r[0]['expires']; $ot->uid = $r[0]['uid']; @@ -87,7 +89,7 @@ class FKOAuthDataStore extends OAuthDataStore $r = dba::select('tokens', ['id', 'secret'], ['client_id' => $consumer->key, 'id' => $nonce, 'expires' => $timestamp], ['limit' => 1]); if (DBM::is_result($r)) { - return new OAuthToken($r['id'], $r['secret']); + return new \OAuthToken($r['id'], $r['secret']); } return null; @@ -124,7 +126,7 @@ class FKOAuthDataStore extends OAuthDataStore return null; } - return new OAuthToken($key, $sec); + return new \OAuthToken($key, $sec); } /** @@ -163,7 +165,7 @@ class FKOAuthDataStore extends OAuthDataStore ); if ($r) { - $ret = new OAuthToken($key, $sec); + $ret = new \OAuthToken($key, $sec); } } diff --git a/src/Network/Probe.php b/src/Network/Probe.php index 7955961838..56abbb7fdc 100644 --- a/src/Network/Probe.php +++ b/src/Network/Probe.php @@ -20,9 +20,10 @@ use Friendica\Protocol\Feed; use Friendica\Util\XML; use dba; -use DomXPath; +use DOMXPath; use DOMDocument; +require_once 'include/dba.php'; require_once 'include/network.php'; require_once "include/crypto.php"; diff --git a/src/Object/Post.php b/src/Object/Post.php index 902435b513..f331538873 100644 --- a/src/Object/Post.php +++ b/src/Object/Post.php @@ -11,6 +11,7 @@ use Friendica\Database\DBM; use Friendica\Model\Contact; use dba; +require_once 'include/dba.php'; require_once 'include/text.php'; require_once 'boot.php'; require_once 'include/conversation.php'; diff --git a/src/ParseUrl.php b/src/ParseUrl.php index 35557067d7..c2c01b8aeb 100644 --- a/src/ParseUrl.php +++ b/src/ParseUrl.php @@ -10,9 +10,10 @@ use Friendica\Object\Image; use Friendica\Util\XML; use dba; -use DomXPath; +use DOMXPath; use DOMDocument; +require_once 'include/dba.php'; require_once "include/network.php"; require_once "include/oembed.php"; @@ -215,7 +216,7 @@ class ParseUrl XML::deleteNode($doc, "ol"); XML::deleteNode($doc, "ul"); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $list = $xpath->query("//meta[@content]"); foreach ($list as $node) { diff --git a/src/Protocol/DFRN.php b/src/Protocol/DFRN.php index 62ada9620a..e9df296258 100644 --- a/src/Protocol/DFRN.php +++ b/src/Protocol/DFRN.php @@ -8,7 +8,6 @@ */ namespace Friendica\Protocol; -use Friendica\App; use Friendica\Core\Config; use Friendica\Core\System; use Friendica\Core\Worker; @@ -22,8 +21,10 @@ use Friendica\Util\XML; use dba; use DOMDocument; -use DomXPath; +use DOMXPath; +require_once 'boot.php'; +require_once 'include/dba.php'; require_once "include/enotify.php"; require_once "include/threads.php"; require_once "include/items.php"; @@ -1298,7 +1299,7 @@ class DFRN case 2: // RINO 2 based on php-encryption try { - $key = \Crypto::createNewRandomKey(); + $key = \Crypto::CreateNewRandomKey(); } catch (\CryptoTestFailedException $ex) { logger('Cannot safely create a key'); return -4; @@ -1307,7 +1308,7 @@ class DFRN return -5; } try { - $data = \Crypto::encrypt($postvars['data'], $key); + $data = \Crypto::Encrypt($postvars['data'], $key); } catch (\CryptoTestFailedException $ex) { logger('Cannot safely perform encryption'); return -6; @@ -2505,13 +2506,13 @@ class DFRN $item['body'] = oembed_html2bbcode($item['body']); - $config = HTMLPurifier_Config::createDefault(); + $config = \HTMLPurifier_Config::createDefault(); $config->set('Cache.DefinitionImpl', null); // we shouldn't need a whitelist, because the bbcode converter // will strip out any unsupported tags. - $purifier = new HTMLPurifier($config); + $purifier = new \HTMLPurifier($config); $item['body'] = $purifier->purify($item['body']); $item['body'] = @html2bbcode($item['body']); @@ -2977,7 +2978,7 @@ class DFRN $doc = new DOMDocument(); @$doc->loadXML($xml); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace("atom", NAMESPACE_ATOM1); $xpath->registerNamespace("thr", NAMESPACE_THREAD); $xpath->registerNamespace("at", NAMESPACE_TOMB); diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 5c6d1a2c06..9090e4b6b2 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -27,6 +27,7 @@ use Friendica\Util\XML; use dba; use SimpleXMLElement; +require_once 'include/dba.php'; require_once 'include/items.php'; require_once 'include/bb2diaspora.php'; require_once 'include/datetime.php'; diff --git a/src/Protocol/Feed.php b/src/Protocol/Feed.php index c33852a7d5..629c2bfdd0 100644 --- a/src/Protocol/Feed.php +++ b/src/Protocol/Feed.php @@ -10,10 +10,11 @@ use Friendica\Database\DBM; use Friendica\Core\System; use dba; use DOMDocument; -use DomXPath; +use DOMXPath; -require_once("include/html2bbcode.php"); -require_once("include/items.php"); +require_once 'include/dba.php'; +require_once 'include/html2bbcode.php'; +require_once 'include/items.php'; /** * @brief This class contain functions to import feeds @@ -55,7 +56,7 @@ class Feed { $doc = new DOMDocument(); @$doc->loadXML(trim($xml)); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace('atom', NAMESPACE_ATOM1); $xpath->registerNamespace('dc', "http://purl.org/dc/elements/1.1/"); $xpath->registerNamespace('content', "http://purl.org/rss/1.0/modules/content/"); diff --git a/src/Protocol/OStatus.php b/src/Protocol/OStatus.php index 2a021c89e9..cadc9a37ea 100644 --- a/src/Protocol/OStatus.php +++ b/src/Protocol/OStatus.php @@ -17,8 +17,9 @@ use Friendica\Util\Lock; use Friendica\Util\XML; use dba; use DOMDocument; -use DomXPath; +use DOMXPath; +require_once 'include/dba.php'; require_once 'include/threads.php'; require_once 'include/html2bbcode.php'; require_once 'include/bbcode.php'; @@ -251,7 +252,7 @@ class OStatus $doc = new DOMDocument(); @$doc->loadXML($xml); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace('atom', NAMESPACE_ATOM1); $xpath->registerNamespace('thr', NAMESPACE_THREAD); $xpath->registerNamespace('georss', NAMESPACE_GEORSS); @@ -329,7 +330,7 @@ class OStatus $doc = new DOMDocument(); @$doc->loadXML($xml); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace('atom', NAMESPACE_ATOM1); $xpath->registerNamespace('thr', NAMESPACE_THREAD); $xpath->registerNamespace('georss', NAMESPACE_GEORSS); @@ -739,7 +740,7 @@ class OStatus if (!@$doc->loadHTML($conversation_data['body'])) { return; } - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $links = $xpath->query('//link'); if ($links) { @@ -779,7 +780,7 @@ class OStatus $doc = new DOMDocument(); @$doc->loadXML($xml); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace('atom', NAMESPACE_ATOM1); $xpath->registerNamespace('thr', NAMESPACE_THREAD); $xpath->registerNamespace('ostatus', NAMESPACE_OSTATUS); @@ -929,7 +930,7 @@ class OStatus if (!@$doc->loadHTML($related_data['body'])) { return; } - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $atom_file = ''; diff --git a/src/Protocol/PortableContact.php b/src/Protocol/PortableContact.php index 2b37a99624..727cce4e1e 100644 --- a/src/Protocol/PortableContact.php +++ b/src/Protocol/PortableContact.php @@ -17,9 +17,10 @@ use Friendica\Model\Profile; use Friendica\Network\Probe; use dba; use DOMDocument; -use DomXPath; +use DOMXPath; use Exception; +require_once 'include/dba.php'; require_once 'include/datetime.php'; require_once 'include/network.php'; require_once 'include/html2bbcode.php'; @@ -512,7 +513,7 @@ class PortableContact $doc = new DOMDocument(); @$doc->loadXML($feedret["body"]); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $xpath->registerNamespace('atom', "http://www.w3.org/2005/Atom"); $entries = $xpath->query('/atom:feed/atom:entry'); @@ -768,7 +769,7 @@ class PortableContact $doc = new DOMDocument(); @$doc->loadHTML($body); - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $list = $xpath->query("//meta[@name]"); diff --git a/src/Util/ExAuth.php b/src/Util/ExAuth.php index f83901e989..054b87aad4 100644 --- a/src/Util/ExAuth.php +++ b/src/Util/ExAuth.php @@ -40,6 +40,7 @@ use Friendica\Database\DBM; use Friendica\Model\User; use dba; +require_once 'include/dba.php'; require_once 'include/dba.php'; class ExAuth @@ -313,7 +314,7 @@ class ExAuth } $file = $lockpath . DIRECTORY_SEPARATOR . $host; - if (Pidfile::isRunningProcess($file)) { + if (PidFile::isRunningProcess($file)) { if (PidFile::killProcess($file)) { $this->writeLog(LOG_INFO, 'Old process was successfully killed'); } else { @@ -323,7 +324,7 @@ class ExAuth } // Now it is safe to create the pid file - Pidfile::create($file); + PidFile::create($file); } /** diff --git a/src/Util/Lock.php b/src/Util/Lock.php index 9c44984459..69b906d03c 100644 --- a/src/Util/Lock.php +++ b/src/Util/Lock.php @@ -14,6 +14,8 @@ use Friendica\Database\DBM; use Memcache; use dba; +require_once 'include/dba.php'; + /** * @brief This class contain Functions for preventing parallel execution of functions */ diff --git a/src/Util/Pidfile.php b/src/Util/Pidfile.php index 9d12b0bd25..00a67d872e 100644 --- a/src/Util/Pidfile.php +++ b/src/Util/Pidfile.php @@ -7,7 +7,7 @@ namespace Friendica\Util; /** * @brief Pidfile class */ -class Pidfile +class PidFile { /** * @brief Read the pid from a given pid file diff --git a/src/Util/XML.php b/src/Util/XML.php index a3cf758da5..e5e649a07c 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -4,7 +4,7 @@ */ namespace Friendica\Util; -use DomXPath; +use DOMXPath; use SimpleXMLElement; /** @@ -407,7 +407,7 @@ class XML */ public static function deleteNode(&$doc, $node) { - $xpath = new DomXPath($doc); + $xpath = new DOMXPath($doc); $list = $xpath->query("//".$node); foreach ($list as $child) { $child->parentNode->removeChild($child); diff --git a/src/Worker/Cron.php b/src/Worker/Cron.php index db0d518cc3..6afa616016 100644 --- a/src/Worker/Cron.php +++ b/src/Worker/Cron.php @@ -9,6 +9,8 @@ use Friendica\Core\Worker; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + Class Cron { public static function execute($parameter = '', $generation = 0) { global $a; diff --git a/src/Worker/CronJobs.php b/src/Worker/CronJobs.php index b59f096d7d..93f1e3a03a 100644 --- a/src/Worker/CronJobs.php +++ b/src/Worker/CronJobs.php @@ -16,6 +16,10 @@ use Friendica\Network\Probe; use Friendica\Protocol\PortableContact; use dba; +require_once 'include/dba.php'; +require_once 'include/post_update.php'; +require_once 'mod/nodeinfo.php'; + class CronJobs { public static function execute($command = '') diff --git a/src/Worker/DBClean.php b/src/Worker/DBClean.php index 45a080400e..8d1228f018 100644 --- a/src/Worker/DBClean.php +++ b/src/Worker/DBClean.php @@ -10,6 +10,8 @@ use Friendica\Core\Config; use Friendica\Core\Worker; use dba; +require_once 'include/dba.php'; + class DBClean { public static function execute($stage = 0) { diff --git a/src/Worker/Expire.php b/src/Worker/Expire.php index 61326fa88e..5a512e9b8e 100644 --- a/src/Worker/Expire.php +++ b/src/Worker/Expire.php @@ -11,6 +11,8 @@ use Friendica\Core\Worker; use Friendica\Database\DBM; use dba; +require_once 'include/dba.php'; + class Expire { public static function execute($param = '', $hook_name = '') { global $a; diff --git a/src/Worker/Notifier.php b/src/Worker/Notifier.php index 7494780444..e3eb6810a3 100644 --- a/src/Worker/Notifier.php +++ b/src/Worker/Notifier.php @@ -15,6 +15,7 @@ use Friendica\Protocol\OStatus; use Friendica\Protocol\Salmon; use dba; +require_once 'include/dba.php'; require_once 'include/queue_fn.php'; require_once 'include/html2plain.php'; require_once 'include/datetime.php'; diff --git a/src/Worker/OnePoll.php b/src/Worker/OnePoll.php index 9024d0d4c9..eaf0058f19 100644 --- a/src/Worker/OnePoll.php +++ b/src/Worker/OnePoll.php @@ -12,6 +12,7 @@ use Friendica\Protocol\Email; use Friendica\Protocol\PortableContact; use dba; +require_once 'include/dba.php'; require_once 'include/follow.php'; Class OnePoll diff --git a/src/Worker/Queue.php b/src/Worker/Queue.php index cb00addc94..8b741b7861 100644 --- a/src/Worker/Queue.php +++ b/src/Worker/Queue.php @@ -14,6 +14,7 @@ use Friendica\Protocol\PortableContact; use Friendica\Protocol\Salmon; use dba; +require_once 'include/dba.php'; require_once 'include/queue_fn.php'; require_once 'include/datetime.php'; require_once 'include/items.php'; diff --git a/src/Worker/RemoveContact.php b/src/Worker/RemoveContact.php index 811b0295fb..4098d66bc5 100644 --- a/src/Worker/RemoveContact.php +++ b/src/Worker/RemoveContact.php @@ -8,6 +8,8 @@ namespace Friendica\Worker; use Friendica\Core\Config; use dba; +require_once 'include/dba.php'; + class RemoveContact { public static function execute($id) {