From 31c55a6fa45f0acd8ef9ff1ef86224778d614819 Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 11 Sep 2020 19:24:40 +0200 Subject: [PATCH 1/5] Rename class for PSR-0 --- src/Util/{Pidfile.php => PidFile.php} | 0 src/Worker/{CleanWorkerqueue.php => CleanWorkerQueue.php} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename src/Util/{Pidfile.php => PidFile.php} (100%) rename src/Worker/{CleanWorkerqueue.php => CleanWorkerQueue.php} (100%) diff --git a/src/Util/Pidfile.php b/src/Util/PidFile.php similarity index 100% rename from src/Util/Pidfile.php rename to src/Util/PidFile.php diff --git a/src/Worker/CleanWorkerqueue.php b/src/Worker/CleanWorkerQueue.php similarity index 100% rename from src/Worker/CleanWorkerqueue.php rename to src/Worker/CleanWorkerQueue.php From e4263f6fe53fecb02fa9bdd8473df10a5ee44a61 Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 11 Sep 2020 19:38:41 +0200 Subject: [PATCH 2/5] Fix PSR-0 for test classes --- tests/{include => legacy}/ApiTest.php | 3 ++- tests/src/Content/Text/BBCode/VideoTest.php | 2 +- tests/src/Core/L10nTest.php | 2 +- .../Lock/{DatabaseLockTest.php => DatabaseLockDriverTest.php} | 0 tests/src/Protocol/ActivityTest.php | 2 +- tests/src/Util/{JSonLDTest.php => JsonLDTest.php} | 0 6 files changed, 5 insertions(+), 4 deletions(-) rename tests/{include => legacy}/ApiTest.php (99%) rename tests/src/Core/Lock/{DatabaseLockTest.php => DatabaseLockDriverTest.php} (100%) rename tests/src/Util/{JSonLDTest.php => JsonLDTest.php} (100%) diff --git a/tests/include/ApiTest.php b/tests/legacy/ApiTest.php similarity index 99% rename from tests/include/ApiTest.php rename to tests/legacy/ApiTest.php index ceeaac6f6..101356e52 100644 --- a/tests/include/ApiTest.php +++ b/tests/legacy/ApiTest.php @@ -3,7 +3,7 @@ * ApiTest class. */ -namespace Friendica\Test; +namespace Friendica\Test\legacy; use Friendica\App; use Friendica\Core\Config\IConfig; @@ -11,6 +11,7 @@ use Friendica\Core\PConfig\IPConfig; use Friendica\Core\Protocol; use Friendica\DI; use Friendica\Network\HTTPException; +use Friendica\Test\FixtureTest; use Friendica\Util\Temporal; use Monolog\Handler\TestHandler; diff --git a/tests/src/Content/Text/BBCode/VideoTest.php b/tests/src/Content/Text/BBCode/VideoTest.php index 2a3cef75a..3d1b24fb7 100644 --- a/tests/src/Content/Text/BBCode/VideoTest.php +++ b/tests/src/Content/Text/BBCode/VideoTest.php @@ -19,7 +19,7 @@ * */ -namespace Friendica\Test\Content\Text\BBCode; +namespace Friendica\Test\src\Content\Text\BBCode; use Friendica\Content\Text\BBCode\Video; use Friendica\Test\MockedTest; diff --git a/tests/src/Core/L10nTest.php b/tests/src/Core/L10nTest.php index 66a96892d..003ff0f8a 100644 --- a/tests/src/Core/L10nTest.php +++ b/tests/src/Core/L10nTest.php @@ -19,7 +19,7 @@ * */ -namespace Friendica\Test\src\Core\L10n; +namespace Friendica\Test\src\Core; use Friendica\Core\L10n; use Friendica\Test\MockedTest; diff --git a/tests/src/Core/Lock/DatabaseLockTest.php b/tests/src/Core/Lock/DatabaseLockDriverTest.php similarity index 100% rename from tests/src/Core/Lock/DatabaseLockTest.php rename to tests/src/Core/Lock/DatabaseLockDriverTest.php diff --git a/tests/src/Protocol/ActivityTest.php b/tests/src/Protocol/ActivityTest.php index 31ff8efc1..edea12fdf 100644 --- a/tests/src/Protocol/ActivityTest.php +++ b/tests/src/Protocol/ActivityTest.php @@ -19,7 +19,7 @@ * */ -namespace Friendica\Test\Protocol; +namespace Friendica\Test\src\Protocol; use Friendica\Protocol\Activity; use Friendica\Protocol\ActivityNamespace; diff --git a/tests/src/Util/JSonLDTest.php b/tests/src/Util/JsonLDTest.php similarity index 100% rename from tests/src/Util/JSonLDTest.php rename to tests/src/Util/JsonLDTest.php From 5365186c6e5f18d9ddb8ec76afbdbc92398426bf Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 11 Sep 2020 19:53:05 +0200 Subject: [PATCH 3/5] Replace deprecated jakub-onderka/php-parallel-lint with php-parallel-lint/php-parallel-lint --- composer.json | 2 +- composer.lock | 104 ++++++++++++++++++++++++++------------------------ 2 files changed, 55 insertions(+), 51 deletions(-) diff --git a/composer.json b/composer.json index 2d6b46574..a0ce423b3 100644 --- a/composer.json +++ b/composer.json @@ -128,7 +128,7 @@ "mikey179/vfsstream": "^1.6", "mockery/mockery": "^1.2", "johnkary/phpunit-speedtrap": "1.1", - "jakub-onderka/php-parallel-lint": "^1.0" + "php-parallel-lint/php-parallel-lint": "^1.2" }, "scripts": { "test": "phpunit" diff --git a/composer.lock b/composer.lock index 9f6f78d00..fae71d6dc 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "7d1fe40c28d815b56d0b5cb323860b26", + "content-hash": "27203cc7da01ff668ba15e03fd17dc94", "packages": [ { "name": "asika/simple-console", @@ -3382,55 +3382,6 @@ ], "time": "2016-01-20T08:20:44+00:00" }, - { - "name": "jakub-onderka/php-parallel-lint", - "version": "v1.0.0", - "source": { - "type": "git", - "url": "https://github.com/JakubOnderka/PHP-Parallel-Lint.git", - "reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/JakubOnderka/PHP-Parallel-Lint/zipball/04fbd3f5fb1c83f08724aa58a23db90bd9086ee8", - "reference": "04fbd3f5fb1c83f08724aa58a23db90bd9086ee8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "jakub-onderka/php-console-highlighter": "~0.3", - "nette/tester": "~1.3", - "squizlabs/php_codesniffer": "~2.7" - }, - "suggest": { - "jakub-onderka/php-console-highlighter": "Highlight syntax in code snippet" - }, - "bin": [ - "parallel-lint" - ], - "type": "library", - "autoload": { - "classmap": [ - "./" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-2-Clause" - ], - "authors": [ - { - "name": "Jakub Onderka", - "email": "ahoj@jakubonderka.cz" - } - ], - "description": "This tool check syntax of PHP files about 20x faster than serial check.", - "homepage": "https://github.com/JakubOnderka/PHP-Parallel-Lint", - "abandoned": "php-parallel-lint/php-parallel-lint", - "time": "2018-02-24T15:31:20+00:00" - }, { "name": "johnkary/phpunit-speedtrap", "version": "v1.1.0", @@ -3635,6 +3586,59 @@ ], "time": "2017-10-19T19:58:43+00:00" }, + { + "name": "php-parallel-lint/php-parallel-lint", + "version": "v1.2.0", + "source": { + "type": "git", + "url": "https://github.com/php-parallel-lint/PHP-Parallel-Lint.git", + "reference": "474f18bc6cc6aca61ca40bfab55139de614e51ca" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-parallel-lint/PHP-Parallel-Lint/zipball/474f18bc6cc6aca61ca40bfab55139de614e51ca", + "reference": "474f18bc6cc6aca61ca40bfab55139de614e51ca", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": ">=5.4.0" + }, + "replace": { + "grogy/php-parallel-lint": "*", + "jakub-onderka/php-parallel-lint": "*" + }, + "require-dev": { + "nette/tester": "^1.3 || ^2.0", + "php-parallel-lint/php-console-highlighter": "~0.3", + "squizlabs/php_codesniffer": "~3.0" + }, + "suggest": { + "php-parallel-lint/php-console-highlighter": "Highlight syntax in code snippet" + }, + "bin": [ + "parallel-lint" + ], + "type": "library", + "autoload": { + "classmap": [ + "./" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-2-Clause" + ], + "authors": [ + { + "name": "Jakub Onderka", + "email": "ahoj@jakubonderka.cz" + } + ], + "description": "This tool check syntax of PHP files about 20x faster than serial check.", + "homepage": "https://github.com/php-parallel-lint/PHP-Parallel-Lint", + "time": "2020-04-04T12:18:32+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "1.0.1", From 1008f408c0062146c6f5ab5da9a0b938d55f508f Mon Sep 17 00:00:00 2001 From: Philipp Date: Fri, 11 Sep 2020 20:14:47 +0200 Subject: [PATCH 4/5] add global init to test setUp --- tests/legacy/ApiTest.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/legacy/ApiTest.php b/tests/legacy/ApiTest.php index 101356e52..ddeb40192 100644 --- a/tests/legacy/ApiTest.php +++ b/tests/legacy/ApiTest.php @@ -50,6 +50,10 @@ class ApiTest extends FixtureTest */ protected function setUp() { + global $API, $called_api; + $API = []; + $called_api = []; + parent::setUp(); /** @var IConfig $config */ From 61014feec35b832b9917280d30eef49c0a01a01b Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 12 Sep 2020 10:01:13 +0200 Subject: [PATCH 5/5] Fix ContactEndpoint & tests --- src/Module/Api/Twitter/ContactEndpoint.php | 8 ++++---- src/Object/Api/Twitter/User.php | 10 +++++----- tests/src/Module/Api/Twitter/ContactEndpointTest.php | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Module/Api/Twitter/ContactEndpoint.php b/src/Module/Api/Twitter/ContactEndpoint.php index f34101971..58807e629 100644 --- a/src/Module/Api/Twitter/ContactEndpoint.php +++ b/src/Module/Api/Twitter/ContactEndpoint.php @@ -73,7 +73,7 @@ abstract class ContactEndpoint extends BaseApi throw new HTTPException\NotFoundException(DI::l10n()->t('User not found')); } - $uid = $user['uid']; + $uid = (int)$user['uid']; } return $uid; @@ -111,7 +111,7 @@ abstract class ContactEndpoint extends BaseApi 'next_cursor_str' => $return['next_cursor_str'], 'previous_cursor' => $return['previous_cursor'], 'previous_cursor_str' => $return['previous_cursor_str'], - 'total_count' => $return['total_count'], + 'total_count' => (int)$return['total_count'], ]; return $return; @@ -153,7 +153,7 @@ abstract class ContactEndpoint extends BaseApi 'pending' => false ]; - $total_count = DBA::count('contact', $condition); + $total_count = (int)DBA::count('contact', $condition); if ($cursor !== -1) { if ($cursor > 0) { @@ -171,7 +171,7 @@ abstract class ContactEndpoint extends BaseApi // Cursor is on the user-specific contact id since it's the sort field if (count($ids)) { $previous_cursor = -$ids[0]; - $next_cursor = $ids[count($ids) -1]; + $next_cursor = (int)$ids[count($ids) -1]; } // No next page diff --git a/src/Object/Api/Twitter/User.php b/src/Object/Api/Twitter/User.php index c646b4924..1cdd699de 100644 --- a/src/Object/Api/Twitter/User.php +++ b/src/Object/Api/Twitter/User.php @@ -89,7 +89,7 @@ class User extends BaseEntity */ public function __construct(array $publicContact, array $apcontact = [], array $userContact = [], $skip_status = false, $include_user_entities = true) { - $this->id = $publicContact['id']; + $this->id = (int)$publicContact['id']; $this->id_str = (string) $publicContact['id']; $this->name = $publicContact['name']; $this->screen_name = $publicContact['nick'] ?: $publicContact['name']; @@ -143,10 +143,10 @@ class User extends BaseEntity $this->notifications = false; // Friendica-specific - $this->uid = $userContact['uid'] ?? 0; - $this->cid = $userContact['id'] ?? 0; - $this->pid = $publicContact['id']; - $this->self = $userContact['self'] ?? false; + $this->uid = (int)$userContact['uid'] ?? 0; + $this->cid = (int)$userContact['id'] ?? 0; + $this->pid = (int)$publicContact['id']; + $this->self = (boolean)$userContact['self'] ?? false; $this->network = $publicContact['network']; $this->statusnet_profile_url = $publicContact['url']; } diff --git a/tests/src/Module/Api/Twitter/ContactEndpointTest.php b/tests/src/Module/Api/Twitter/ContactEndpointTest.php index cb8ec57e2..e23b83682 100644 --- a/tests/src/Module/Api/Twitter/ContactEndpointTest.php +++ b/tests/src/Module/Api/Twitter/ContactEndpointTest.php @@ -234,7 +234,7 @@ class ContactEndpointTest extends FixtureTest 'uid' => 42, 'cid' => 44, 'pid' => 45, - 'self' => 0, + 'self' => false, 'network' => 'dfrn', 'statusnet_profile_url' => 'http://localhost/profile/friendcontact', ];