namespace Friendica;
+use DateTime;
use Friendica\Network\HTTPException\InternalServerErrorException;
+use Psr\Http\Message\UriInterface;
/**
* The Entity classes directly inheriting from this abstract class are meant to represent a single business entity.
* Since these objects aren't meant to be using any dependency, including logging, unit tests can and must be
* written for each and all of their methods
*
- * @property-read int $id
+ * @property-read int|null $id
* @property-read int $uid
* @property-read string $verb
- * @property-read int $type
+ * @property-read int|string $type
* @property-read int $actorId
* @property-read int $targetUriId
- * @property-read int $parentUriId
- * @property-read \DateTime $created
+ * @property-read int|null $parentUriId
+ * @property-read \DateTime|string $created
* @property-read bool $seen
* @property-read bool $dismissed
+ * @property-read string $name
+ * @property-read UriInterface $url
+ * @property-read UriInterface $photo
+ * @property-read DateTime $date
+ * @property-read string|null $msg
+ * @property-read UriInterface $link
+ * @property-read int|null $itemId
+ * @property-read int|null $parent
+ * @property-read string|null $otype
+ * @property-read string|null $name_cache
+ * @property-read string|null $msg_cache
+ * @property-read int|null $uriId
+ * @property-read string $cookie_hash
+ * @property-read string $user_agent
+ * @property-read bool $trusted
+ * @property-read string|null $last_used
*/
abstract class BaseEntity extends BaseDataTransferObject
{
use Friendica\App;
use Friendica\Core\Addon;
-use Friendica\Core\Config\Util\ConfigFileManager;
use Friendica\Core\Config\ValueObject\Cache;
use Friendica\Core\Renderer;
use Friendica\Core\Update;
use Friendica\Core\Config\Factory\Config;
use Friendica\Module\BaseAdmin;
use Friendica\Network\HTTPClient\Client\HttpClientAccept;
-use Friendica\Network\HTTPException\ServiceUnavailableException;
use Friendica\Network\Probe;
use Friendica\Util\DateTimeFormat;
$table_definition_cache = DBA::getVariable('table_definition_cache');
$table_open_cache = DBA::getVariable('table_open_cache');
if (!empty($table_definition_cache) && !empty($table_open_cache)) {
- $suggested_definition_cache = min(400 + round($table_open_cache / 2, 1), 2000);
+ $suggested_definition_cache = min(400 + round((int) $table_open_cache / 2, 1), 2000);
if ($suggested_definition_cache > $table_definition_cache) {
$warningtext[] = DI::l10n()->t('Your table_definition_cache is too low (%d). This can lead to the database error "Prepared statement needs to be re-prepared". Please set it at least to %d. See <a href="%s">here</a> for more information.<br />', $table_definition_cache, $suggested_definition_cache, 'https://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_table_definition_cache');
}
/**
* Set boundaries for the "link" header
- * @param array $boundaries
+ *
* @param int|\DateTime $id
*/
protected static function setBoundaries($id)
use DOMDocument;
use DOMElement;
-use Friendica\App;
+use Friendica\App\Arguments;
+use Friendica\App\BaseURL;
use Friendica\BaseModule;
use Friendica\Core\Config\Capability\IManageConfigValues;
use Friendica\Core\L10n;
/** @var string */
private $basePath;
- public function __construct(BasePath $basePath, IManageConfigValues $config, L10n $l10n, App\baseUrl $baseUrl, App\Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
+ public function __construct(BasePath $basePath, IManageConfigValues $config, L10n $l10n, BaseURL $baseUrl, Arguments $args, LoggerInterface $logger, Profiler $profiler, Response $response, array $server, array $parameters = [])
{
parent::__construct($l10n, $baseUrl, $args, $logger, $profiler, $response, $server, $parameters);
*/
protected function rawContent(array $request = [])
{
- /** @var DOMDocument $xml */
- XML::fromArray([
- 'OpenSearchDescription' => [
- '@attributes' => [
- 'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
+ XML::fromArray(
+ [
+ 'OpenSearchDescription' => [
+ '@attributes' => [
+ 'xmlns' => 'http://a9.com/-/spec/opensearch/1.1/',
+ ],
+ 'ShortName' => $this->baseUrl->getHost(),
+ 'Description' => $this->l10n->t('Search in Friendica %s', $this->baseUrl->getHost()),
+ 'Contact' => 'https://github.com/friendica/friendica/issues',
+ 'InputEncoding' => 'UTF-8',
+ 'OutputEncoding' => 'UTF-8',
+ 'Developer' => 'Friendica Developer Team',
],
- 'ShortName' => $this->baseUrl->getHost(),
- 'Description' => $this->l10n->t('Search in Friendica %s', $this->baseUrl->getHost()),
- 'Contact' => 'https://github.com/friendica/friendica/issues',
- 'InputEncoding' => 'UTF-8',
- 'OutputEncoding' => 'UTF-8',
- 'Developer' => 'Friendica Developer Team',
],
- ], $xml);
+ /** @var DOMDocument $xml */
+ $xml
+ );
/** @var DOMElement $parent */
$parent = $xml->getElementsByTagName('OpenSearchDescription')[0];
// Detect the server URL
$open_id_obj = new LightOpenID(DI::baseUrl()->getHost());
+ /** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
$open_id_obj->identity = $authId;
+ /** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
$session->set('openid_server', $open_id_obj->discover($open_id_obj->identity));
if (\Friendica\Module\Register::getPolicy() === \Friendica\Module\Register::CLOSED) {
namespace Friendica\Module\Special;
-use Friendica\App;
+use Friendica\App\Arguments;
+use Friendica\App\Request;
use Friendica\Core\L10n;
use Friendica\Core\Renderer;
use Friendica\Core\Session\Model\UserSession;
use Friendica\Core\System;
use Friendica\Module\Response;
+use Friendica\Network\HTTPException as NetworkHTTPException;
use Psr\Log\LoggerInterface;
/**
protected $l10n;
/** @var LoggerInterface */
protected $logger;
- /** @var App\Arguments */
+ /** @var Arguments */
protected $args;
/** @var bool */
protected $isSiteAdmin;
/** @var string */
protected $requestId;
- public function __construct(L10n $l10n, LoggerInterface $logger, App\Arguments $args, UserSession $session, App\Request $request, array $server = [])
+ public function __construct(L10n $l10n, LoggerInterface $logger, Arguments $args, UserSession $session, Request $request, array $server = [])
{
$this->logger = $logger;
$this->l10n = $l10n;
*
* Fills in the blanks if title or descriptions aren't provided by the exception.
*
- * @param \Friendica\Network\HTTPException $e
- *
* @return array ['$title' => ..., '$description' => ...]
*/
- private function getVars(\Friendica\Network\HTTPException $e)
+ private function getVars(NetworkHTTPException $e)
{
// Explanations are mostly taken from https://en.wikipedia.org/wiki/List_of_HTTP_status_codes
$vars = [
/**
* Displays a bare message page with no theming at all.
*
- * @param \Friendica\Network\HTTPException $e
- *
* @throws \Exception
*/
- public function rawContent(\Friendica\Network\HTTPException $e)
+ public function rawContent(NetworkHTTPException $e)
{
$content = '';
// We can't use a constructor parameter for this response object because we
// are in an Exception context where we don't want an existing Response.
+ $reason = ($e instanceof NetworkHTTPException) ? $e->getDescription() : $e->getMessage();
$response = new Response();
- $response->setStatus($e->getCode(), $e->getDescription());
+ $response->setStatus($e->getCode(), $reason);
$response->addContent($content);
System::echoResponse($response->generate());
System::exit();
/**
* Returns a content string that can be integrated in the current theme.
*
- * @param \Friendica\Network\HTTPException $e
- *
* @return string
* @throws \Exception
*/
- public function content(\Friendica\Network\HTTPException $e): string
+ public function content(NetworkHTTPException $e): string
{
if ($e->getCode() >= 400) {
$this->logger->debug('Exit with error',
use Psr\Http\Message\UriInterface;
/**
- * @property-read $type
- * @property-read $name
- * @property-read $url
- * @property-read $photo
- * @property-read $date
- * @property-read $msg
- * @property-read $uid
- * @property-read $link
- * @property-read $itemId
- * @property-read $parent
- * @property-read $seen
- * @property-read $verb
- * @property-read $otype
- * @property-read $name_cache
- * @property-read $msg_cache
- * @property-read $uriId
- * @property-read $parentUriId
- * @property-read $id
+ * @property-read string $type
+ * @property-read string $name
+ * @property-read UriInterface $url
+ * @property-read UriInterface $photo
+ * @property-read DateTime $date
+ * @property-read string|null $msg
+ * @property-read int $uid
+ * @property-read UriInterface $link
+ * @property-read int|null $itemId
+ * @property-read int|null $parent
+ * @property-read bool $seen
+ * @property-read string $verb
+ * @property-read string|null $otype
+ * @property-read string|null $name_cache
+ * @property-read string|null $msg_cache
+ * @property-read int|null $uriId
+ * @property-read int|null $parentUriId
+ * @property-read int|null $id
*
* @deprecated since 2022.05 Use \Friendica\Navigation\Notifications\Entity\Notification instead
*/
// Otherwise it's probably an openid.
try {
$openid = new LightOpenID($this->baseUrl->getHost());
+ /** @phpstan-ignore-next-line $openid->identity is private, but will be set via magic setter */
$openid->identity = $openid_url;
$this->session->set('openid', $openid_url);
$this->session->set('remember', $remember);
* Class TrustedBrowser
*
*
- * @property-read $cookie_hash
- * @property-read $uid
- * @property-read $user_agent
- * @property-read $trusted
- * @property-read $created
- * @property-read $last_used
+ * @property-read string $cookie_hash
+ * @property-read int $uid
+ * @property-read string $user_agent
+ * @property-read bool $trusted
+ * @property-read string $created
+ * @property-read string|null $last_used
* @package Friendica\Model\TwoFactor
*/
class TrustedBrowser extends BaseEntity