From 037dac988edb0f49cfa526e4d77c311b71f25e35 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 5 Jul 2023 21:29:12 +0200 Subject: [PATCH 1/5] Update json-ld dependency --- composer.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composer.lock b/composer.lock index af9186e8d..1555bc9be 100644 --- a/composer.lock +++ b/composer.lock @@ -720,11 +720,11 @@ }, { "name": "friendica/json-ld", - "version": "1.1.2", + "version": "1.1.3", "source": { "type": "git", "url": "https://git.friendi.ca/friendica/php-json-ld", - "reference": "5f6ea87b261d346e57f03457ae906e6835f0205f" + "reference": "8d1d421b1dfd493adc058a79541a257d4bfadb01" }, "require": { "ext-json": "*", @@ -760,7 +760,7 @@ "Semantic Web", "jsonld" ], - "time": "2023-02-20T21:56:16+00:00" + "time": "2023-05-23T05:58:06+00:00" }, { "name": "fxp/composer-asset-plugin", From 5fbdcd4a26728facad668572565722f7c8b74d9c Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 5 Jul 2023 21:43:03 +0200 Subject: [PATCH 2/5] Fix PHPUnit 10 deprecations --- tests/Util/Database/StaticDatabase.php | 1 - tests/src/App/BaseURLTest.php | 2 +- tests/src/Content/Text/BBCodeTest.php | 3 +++ tests/src/Model/User/CookieTest.php | 7 ++++--- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/Util/Database/StaticDatabase.php b/tests/Util/Database/StaticDatabase.php index be2ec99f0..3ae497e9a 100644 --- a/tests/Util/Database/StaticDatabase.php +++ b/tests/Util/Database/StaticDatabase.php @@ -60,7 +60,6 @@ class StaticDatabase extends Database $this->driver = 'pdo'; $this->connection = self::$staticConnection; $this->connected = true; - $this->emulate_prepares = false; return $this->connected; } diff --git a/tests/src/App/BaseURLTest.php b/tests/src/App/BaseURLTest.php index e45b30b20..fb79fd4d3 100644 --- a/tests/src/App/BaseURLTest.php +++ b/tests/src/App/BaseURLTest.php @@ -178,7 +178,7 @@ class BaseURLTest extends MockedTest public function testRedirectException() { self::expectException(InternalServerErrorException::class); - self::expectErrorMessage('https://friendica.other is not a relative path, please use System::externalRedirect'); + self::expectExceptionMessage('https://friendica.other is not a relative path, please use System::externalRedirect'); $config = new ReadOnlyFileConfig(new Cache([ 'system' => [ diff --git a/tests/src/Content/Text/BBCodeTest.php b/tests/src/Content/Text/BBCodeTest.php index 889b12caa..fc8fd4bff 100644 --- a/tests/src/Content/Text/BBCodeTest.php +++ b/tests/src/Content/Text/BBCodeTest.php @@ -28,6 +28,9 @@ use Friendica\Test\FixtureTest; class BBCodeTest extends FixtureTest { + /** @var \HTMLPurifier */ + public $HTMLPurifier; + protected function setUp(): void { parent::setUp(); diff --git a/tests/src/Model/User/CookieTest.php b/tests/src/Model/User/CookieTest.php index 372645bf3..ebe78764b 100644 --- a/tests/src/Model/User/CookieTest.php +++ b/tests/src/Model/User/CookieTest.php @@ -231,11 +231,12 @@ class CookieTest extends MockedTest $data = json_decode(StaticCookie::$_COOKIE[Cookie::NAME]); - self::assertObjectHasAttribute('uid', $data); + self::assertIsObject($data); + self::assertTrue(property_exists($data, 'uid')); self::assertEquals($uid, $data->uid); - self::assertObjectHasAttribute('hash', $data); + self::assertTrue(property_exists($data, 'hash')); self::assertEquals($hash, $data->hash); - self::assertObjectHasAttribute('ip', $data); + self::assertTrue(property_exists($data, 'ip')); self::assertEquals($remoteIp, $data->ip); self::assertLessThanOrEqual(time() + Cookie::DEFAULT_EXPIRE * 24 * 60 * 60, StaticCookie::$_EXPIRE); From f693032109b1b5ef90724ef0132cd8cfa7ae52e1 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 5 Jul 2023 21:58:20 +0200 Subject: [PATCH 3/5] Fix dynamic properties in API\Twitter\User object --- src/Object/Api/Twitter/User.php | 45 ++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/src/Object/Api/Twitter/User.php b/src/Object/Api/Twitter/User.php index 60a7f9818..3ad5c5461 100644 --- a/src/Object/Api/Twitter/User.php +++ b/src/Object/Api/Twitter/User.php @@ -24,8 +24,8 @@ namespace Friendica\Object\Api\Twitter; use Friendica\BaseDataTransferObject; use Friendica\Content\ContactSelector; use Friendica\Content\Text\BBCode; -use Friendica\Core\Protocol; use Friendica\Model\Contact; +use Friendica\Network\HTTPException\InternalServerErrorException; use Friendica\Util\DateTimeFormat; use Friendica\Util\Proxy; @@ -82,6 +82,42 @@ class User extends BaseDataTransferObject protected $withheld_in_countries; /** @var string */ protected $withheld_scope; + /** @var string */ + protected $profile_image_url; + /** @var bool */ + protected $follow_request_sent; + /** @var string */ + protected $profile_image_url_large; + /** @var string */ + protected $profile_image_url_profile_size; + /** @var int */ + protected $utc_offset; + /** @var string */ + protected $time_zone; + /** @var bool */ + protected $geo_enabled; + /** @var null */ + protected $lang; + /** @var bool */ + protected $contributors_enabled; + /** @var bool */ + protected $is_translator; + /** @var bool */ + protected $is_translation_enabled; + /** @var bool */ + protected $following; + /** @var bool */ + protected $statusnet_blocking; + /** @var bool */ + protected $notifications; + /** @var int */ + protected $uid; + /** @var int */ + protected $pid; + /** @var int */ + protected $cid; + /** @var mixed */ + protected $statusnet_profile_url; /** * Missing fields: @@ -95,11 +131,12 @@ class User extends BaseDataTransferObject * @param array $publicContact Full contact table record with uid = 0 * @param array $apcontact Optional full apcontact table record * @param array $userContact Optional full contact table record with uid != 0 - * @param bool $skip_status Whether to remove the last status property, currently unused + * @param null $status * @param bool $include_user_entities Whether to add the entities property - * @throws \Friendica\Network\HTTPException\InternalServerErrorException + * + * @throws InternalServerErrorException */ - public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], $status = null, $include_user_entities = true) + public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], $status = null, bool $include_user_entities = true) { $uid = $userContact['uid'] ?? 0; From 00cd346255fd5b1aa758a362c2ae2cfb2522e961 Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 5 Jul 2023 22:02:58 +0200 Subject: [PATCH 4/5] Fix XML deprecation --- src/Util/XML.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Util/XML.php b/src/Util/XML.php index e5fa4009f..c35f19b8a 100644 --- a/src/Util/XML.php +++ b/src/Util/XML.php @@ -118,7 +118,7 @@ class XML $namespace = null; } - $element->addAttribute($attr_key, $attr_value, $namespace); + $element->addAttribute($attr_key, $attr_value ?? '', $namespace); } continue; From f68dd99518058f9076e4c70da5639fe77816dbdb Mon Sep 17 00:00:00 2001 From: Philipp Date: Wed, 5 Jul 2023 22:20:52 +0200 Subject: [PATCH 5/5] Some more deprecation fixups --- src/Collection/Api/Notifications.php | 1 + src/Util/ACLFormatter.php | 9 ++++++--- src/Util/ReversedFileReader.php | 4 +++- tests/Util/Intercept.php | 2 +- tests/src/Database/DatabaseTest.php | 9 +++++++++ 5 files changed, 20 insertions(+), 5 deletions(-) diff --git a/src/Collection/Api/Notifications.php b/src/Collection/Api/Notifications.php index c2ccf2cff..4bb1eaa56 100644 --- a/src/Collection/Api/Notifications.php +++ b/src/Collection/Api/Notifications.php @@ -29,6 +29,7 @@ class Notifications extends BaseCollection /** * @return Notification */ + #[\ReturnTypeWillChange] public function current() { return parent::current(); diff --git a/src/Util/ACLFormatter.php b/src/Util/ACLFormatter.php index f7a0894e1..cd398fc28 100644 --- a/src/Util/ACLFormatter.php +++ b/src/Util/ACLFormatter.php @@ -35,7 +35,7 @@ final class ACLFormatter * * @return array The array based on the IDs (empty in case there is no list) */ - public function expand(string $acl_string = null) + public function expand(string $acl_string = null): array { // In case there is no ID list, return empty array (=> no ACL set) if (empty($acl_string)) { @@ -55,7 +55,7 @@ final class ACLFormatter * @param string|null $acl_string * @return string */ - public function sanitize(string $acl_string = null) + public function sanitize(string $acl_string = null): string { if (empty($acl_string)) { return ''; @@ -107,10 +107,13 @@ final class ACLFormatter * * @return string */ - function toString($permissions) { + function toString($permissions): string + { $return = ''; if (is_array($permissions)) { $item = $permissions; + } elseif (empty($permissions)) { + return ''; } else { $item = explode(',', $permissions); } diff --git a/src/Util/ReversedFileReader.php b/src/Util/ReversedFileReader.php index fdd15bec9..58fb2cb3f 100644 --- a/src/Util/ReversedFileReader.php +++ b/src/Util/ReversedFileReader.php @@ -89,7 +89,7 @@ class ReversedFileReader implements \Iterator * * @return string|null Depending on data being buffered */ - private function _readline() + private function _readline(): ?string { $buffer = & $this->buffer; while (true) { @@ -112,6 +112,7 @@ class ReversedFileReader implements \Iterator * @see Iterator::next() * @return void */ + #[\ReturnTypeWillChange] public function next() { ++$this->key; @@ -124,6 +125,7 @@ class ReversedFileReader implements \Iterator * @see Iterator::rewind() * @return void */ + #[\ReturnTypeWillChange] public function rewind() { if ($this->filesize > 0) { diff --git a/tests/Util/Intercept.php b/tests/Util/Intercept.php index 27b558fc5..483d274fc 100644 --- a/tests/Util/Intercept.php +++ b/tests/Util/Intercept.php @@ -37,7 +37,7 @@ class Intercept extends php_user_filter public static $cache = ''; /** @noinspection PhpMissingParentCallCommonInspection */ - public function filter($in, $out, &$consumed, $closing) + public function filter($in, $out, &$consumed, $closing): int { while ($bucket = stream_bucket_make_writeable($in)) { self::$cache .= $bucket->data; diff --git a/tests/src/Database/DatabaseTest.php b/tests/src/Database/DatabaseTest.php index e90683461..c431a5294 100644 --- a/tests/src/Database/DatabaseTest.php +++ b/tests/src/Database/DatabaseTest.php @@ -30,6 +30,15 @@ class DatabaseTest extends FixtureTest { use CreateDatabaseTrait; + /** + * @var Cache + */ + protected $configCache; + /** + * @var ConfigFileManager + */ + protected $configFileManager; + protected function setUp(): void { $this->setUpVfsDir();