1
1
Fork 0

PHPStan: Fix missing requires/namespaces

This commit is contained in:
Hypolite Petovan 2017-12-17 15:24:57 -05:00
parent e40917b792
commit 10b72b0e9e
35 changed files with 89 additions and 37 deletions

View file

@ -14,6 +14,9 @@ use Detection\MobileDetect;
use Exception;
require_once 'boot.php';
require_once 'include/dba.php';
/**
*
* class: App

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

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;

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
*

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

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

View file

@ -13,6 +13,8 @@ use Friendica\Util\Lock;
use dba;
require_once 'include/dba.php';
/**
* @file src/Core/Worker.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
*

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

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';
/**

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

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';
/**

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

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

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

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

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

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

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

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

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

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

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

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);
}
/**

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

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

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

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;

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

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

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;

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

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

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

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