Browse Source

PHPStan: Fix missing requires/namespaces

tags/3.6
Hypolite Petovan 2 years ago
parent
commit
10b72b0e9e
35 changed files with 89 additions and 37 deletions
  1. +3
    -0
      src/App.php
  2. +2
    -0
      src/Content/ForumManager.php
  3. +3
    -1
      src/Core/Cache.php
  4. +2
    -0
      src/Core/Config.php
  5. +2
    -1
      src/Core/NotificationsManager.php
  6. +2
    -0
      src/Core/PConfig.php
  7. +2
    -0
      src/Core/Worker.php
  8. +2
    -0
      src/Database/DBM.php
  9. +3
    -1
      src/Database/DBStructure.php
  10. +1
    -0
      src/Model/Contact.php
  11. +1
    -0
      src/Model/GContact.php
  12. +1
    -0
      src/Model/Group.php
  13. +2
    -0
      src/Model/Photo.php
  14. +2
    -1
      src/Model/User.php
  15. +7
    -5
      src/Network/FKOAuthDataStore.php
  16. +2
    -1
      src/Network/Probe.php
  17. +1
    -0
      src/Object/Post.php
  18. +3
    -2
      src/ParseUrl.php
  19. +8
    -7
      src/Protocol/DFRN.php
  20. +1
    -0
      src/Protocol/Diaspora.php
  21. +5
    -4
      src/Protocol/Feed.php
  22. +7
    -6
      src/Protocol/OStatus.php
  23. +4
    -3
      src/Protocol/PortableContact.php
  24. +3
    -2
      src/Util/ExAuth.php
  25. +2
    -0
      src/Util/Lock.php
  26. +1
    -1
      src/Util/Pidfile.php
  27. +2
    -2
      src/Util/XML.php
  28. +2
    -0
      src/Worker/Cron.php
  29. +4
    -0
      src/Worker/CronJobs.php
  30. +2
    -0
      src/Worker/DBClean.php
  31. +2
    -0
      src/Worker/Expire.php
  32. +1
    -0
      src/Worker/Notifier.php
  33. +1
    -0
      src/Worker/OnePoll.php
  34. +1
    -0
      src/Worker/Queue.php
  35. +2
    -0
      src/Worker/RemoveContact.php

+ 3
- 0
src/App.php View File

@@ -14,6 +14,9 @@ use Detection\MobileDetect;

use Exception;

require_once 'boot.php';
require_once 'include/dba.php';

/**
*
* class: App


+ 2
- 0
src/Content/ForumManager.php View File

@@ -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
*/


+ 3
- 1
src/Core/Cache.php View File

@@ -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;


+ 2
- 0
src/Core/Config.php View File

@@ -11,6 +11,8 @@ namespace Friendica\Core;
use Friendica\Database\DBM;
use dba;

require_once 'include/dba.php';

/**
* @brief Arbitrary sytem configuration storage
*


+ 2
- 1
src/Core/NotificationsManager.php View File

@@ -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';


+ 2
- 0
src/Core/PConfig.php View File

@@ -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


+ 2
- 0
src/Core/Worker.php View File

@@ -13,6 +13,8 @@ use Friendica\Util\Lock;

use dba;

require_once 'include/dba.php';

/**
* @file src/Core/Worker.php
*


+ 2
- 0
src/Database/DBM.php View File

@@ -6,6 +6,8 @@ namespace Friendica\Database;

use dba;

require_once 'include/dba.php';

/**
* @brief This class contain functions for the database management
*


+ 3
- 1
src/Database/DBStructure.php View File

@@ -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") {


+ 1
- 0
src/Model/Contact.php View File

@@ -20,6 +20,7 @@ use Friendica\Protocol\Salmon;
use dba;

require_once 'boot.php';
require_once 'include/dba.php';
require_once 'include/text.php';

/**


+ 1
- 0
src/Model/GContact.php View File

@@ -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';



+ 1
- 0
src/Model/Group.php View File

@@ -11,6 +11,7 @@ use Friendica\Database\DBM;
use dba;

require_once 'boot.php';
require_once 'include/dba.php';
require_once 'include/text.php';

/**


+ 2
- 0
src/Model/Photo.php View File

@@ -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
*/


+ 2
- 1
src/Model/User.php View File

@@ -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');


+ 7
- 5
src/Network/FKOAuthDataStore.php View File

@@ -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);
}
}



+ 2
- 1
src/Network/Probe.php View File

@@ -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";



+ 1
- 0
src/Object/Post.php View File

@@ -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';


+ 3
- 2
src/ParseUrl.php View File

@@ -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) {


+ 8
- 7
src/Protocol/DFRN.php View File

@@ -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);


+ 1
- 0
src/Protocol/Diaspora.php View File

@@ -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';


+ 5
- 4
src/Protocol/Feed.php View File

@@ -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/");


+ 7
- 6
src/Protocol/OStatus.php View File

@@ -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 = '';



+ 4
- 3
src/Protocol/PortableContact.php View File

@@ -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]");



+ 3
- 2
src/Util/ExAuth.php View File

@@ -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);
}

/**


+ 2
- 0
src/Util/Lock.php View File

@@ -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
*/


+ 1
- 1
src/Util/Pidfile.php View File

@@ -7,7 +7,7 @@ namespace Friendica\Util;
/**
* @brief Pidfile class
*/
class Pidfile
class PidFile
{
/**
* @brief Read the pid from a given pid file


+ 2
- 2
src/Util/XML.php View File

@@ -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);


+ 2
- 0
src/Worker/Cron.php View File

@@ -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;


+ 4
- 0
src/Worker/CronJobs.php View File

@@ -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 = '')


+ 2
- 0
src/Worker/DBClean.php View File

@@ -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) {



+ 2
- 0
src/Worker/Expire.php View File

@@ -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;


+ 1
- 0
src/Worker/Notifier.php View File

@@ -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';


+ 1
- 0
src/Worker/OnePoll.php View File

@@ -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


+ 1
- 0
src/Worker/Queue.php View File

@@ -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';


+ 2
- 0
src/Worker/RemoveContact.php View File

@@ -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) {



Loading…
Cancel
Save