From 9987c90fafc078cb3064b93f904c0c2538470627 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 22 Dec 2024 16:29:47 +0000 Subject: [PATCH 01/26] Refactor getting the basepath --- static/dependencies.config.php | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 615319336b..5ca2f16726 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -47,6 +47,12 @@ use Friendica\Network; use Friendica\Util; use Psr\Log\LoggerInterface; +$basepath = (function() { + $path = dirname(__FILE__, 2); + + return ($realpath = realpath($path)) ? $realpath : $path; +})(); + return [ '*' => [ // marks all class result as shared for other creations, so there's just @@ -56,7 +62,7 @@ return [ \Friendica\Core\Addon\Capability\ICanLoadAddons::class => [ 'instanceOf' => \Friendica\Core\Addon\Model\AddonLoader::class, 'constructParams' => [ - [Dice::INSTANCE => '$basepath'], + $basepath, [Dice::INSTANCE => Dice::SELF], ], ], @@ -83,7 +89,7 @@ return [ ], \Friendica\Core\Hooks\Util\StrategiesFileManager::class => [ 'constructParams' => [ - [Dice::INSTANCE => '$basepath'], + $basepath, ], 'call' => [ ['loadConfig'], @@ -108,7 +114,7 @@ return [ 'instanceOf' => Config\Factory\Config::class, 'call' => [ ['createConfigFileManager', [ - [Dice::INSTANCE => '$basepath'], + $basepath, $_SERVER, ], Dice::CHAIN_CALL], ], @@ -123,7 +129,7 @@ return [ 'call' => [ ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL], ['determine', [ - [Dice::INSTANCE => '$basepath'] + $basepath, ], Dice::CHAIN_CALL], ], ], @@ -141,7 +147,7 @@ return [ ], DbaDefinition::class => [ 'constructParams' => [ - [Dice::INSTANCE => '$basepath'], + $basepath, ], 'call' => [ ['load', [false], Dice::CHAIN_CALL], @@ -149,7 +155,7 @@ return [ ], ViewDefinition::class => [ 'constructParams' => [ - [Dice::INSTANCE => '$basepath'], + $basepath, ], 'call' => [ ['load', [false], Dice::CHAIN_CALL], @@ -187,7 +193,7 @@ return [ ], App\Page::class => [ 'constructParams' => [ - [Dice::INSTANCE => '$basepath'], + $basepath, ], ], \Psr\Log\LoggerInterface::class => [ @@ -246,7 +252,7 @@ return [ ], \Friendica\Core\System::class => [ 'constructParams' => [ - [Dice::INSTANCE => '$basepath'], + $basepath, ], ], App\Router::class => [ From 704ddc2089143cb309fe4c83ca4e9f303936cb1d Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 22 Dec 2024 18:03:54 +0000 Subject: [PATCH 02/26] simplify basepath --- static/dependencies.config.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 5ca2f16726..035862f14d 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -47,10 +47,11 @@ use Friendica\Network; use Friendica\Util; use Psr\Log\LoggerInterface; +/** + * @var string $basepath The base path of the Friendica installation without trailing slash + */ $basepath = (function() { - $path = dirname(__FILE__, 2); - - return ($realpath = realpath($path)) ? $realpath : $path; + return dirname(__FILE__, 2); })(); return [ From 75772d874f8349b5a19396f2bbae6c08c6880492 Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 22 Dec 2024 18:47:57 +0000 Subject: [PATCH 03/26] refactor BasePathTest --- tests/Unit/Util/BasePathTest.php | 83 ++++++++++++++++++++++++++++++++ tests/src/Util/BasePathTest.php | 82 ------------------------------- 2 files changed, 83 insertions(+), 82 deletions(-) create mode 100644 tests/Unit/Util/BasePathTest.php delete mode 100644 tests/src/Util/BasePathTest.php diff --git a/tests/Unit/Util/BasePathTest.php b/tests/Unit/Util/BasePathTest.php new file mode 100644 index 0000000000..e969f963af --- /dev/null +++ b/tests/Unit/Util/BasePathTest.php @@ -0,0 +1,83 @@ + [ + 'server' => [], + 'baseDir' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + ], + 'relative' => [ + 'server' => [], + 'baseDir' => 'config', + 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + ], + 'document_root' => [ + 'server' => [ + 'DOCUMENT_ROOT' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + ], + 'baseDir' => '/noooop', + 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + ], + 'pwd' => [ + 'server' => [ + 'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + ], + 'baseDir' => '/noooop', + 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + ], + 'no_overwrite' => [ + 'server' => [ + 'DOCUMENT_ROOT' => dirname(__DIR__, 3), + 'PWD' => dirname(__DIR__, 3), + ], + 'baseDir' => 'config', + 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + ], + 'no_overwrite_if_invalid' => [ + 'server' => [ + 'DOCUMENT_ROOT' => '/nopopop', + 'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + ], + 'baseDir' => '/noatgawe22fafa', + 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + ] + ]; + } + + /** + * Test the basepath determination + * @dataProvider getDataPaths + */ + public function testDetermineBasePath(array $server, string $baseDir, string $expected): void + { + $basepath = new BasePath($baseDir, $server); + self::assertEquals($expected, $basepath->getPath()); + } + + /** + * Test the basepath determination with a complete wrong path + */ + public function testFailedBasePath(): void + { + $basepath = new BasePath('/now23452sgfgas', []); + + $this->expectException(\Exception::class); + $this->expectExceptionMessage('\'/now23452sgfgas\' is not a valid basepath'); + + $basepath->getPath(); + } +} diff --git a/tests/src/Util/BasePathTest.php b/tests/src/Util/BasePathTest.php deleted file mode 100644 index bbcaeb359b..0000000000 --- a/tests/src/Util/BasePathTest.php +++ /dev/null @@ -1,82 +0,0 @@ - [ - 'server' => [], - 'input' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - ], - 'relative' => [ - 'server' => [], - 'input' => 'config', - 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - ], - 'document_root' => [ - 'server' => [ - 'DOCUMENT_ROOT' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - ], - 'input' => '/noooop', - 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - ], - 'pwd' => [ - 'server' => [ - 'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - ], - 'input' => '/noooop', - 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - ], - 'no_overwrite' => [ - 'server' => [ - 'DOCUMENT_ROOT' => dirname(__DIR__, 3), - 'PWD' => dirname(__DIR__, 3), - ], - 'input' => 'config', - 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - ], - 'no_overwrite_if_invalid' => [ - 'server' => [ - 'DOCUMENT_ROOT' => '/nopopop', - 'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - ], - 'input' => '/noatgawe22fafa', - 'output' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - ] - ]; - } - - /** - * Test the basepath determination - * @dataProvider dataPaths - */ - public function testDetermineBasePath(array $server, $input, $output) - { - $basepath = new BasePath($input, $server); - self::assertEquals($output, $basepath->getPath()); - } - - /** - * Test the basepath determination with a complete wrong path - */ - public function testFailedBasePath() - { - $this->expectException(\Exception::class); - $this->expectExceptionMessageMatches("/(.*) is not a valid basepath/"); - - $basepath = new BasePath('/now23452sgfgas', []); - $basepath->getPath(); - } -} From 6f570a08e53ced88e31a73ac0c658338d9c30abe Mon Sep 17 00:00:00 2001 From: Art4 Date: Sun, 22 Dec 2024 18:48:46 +0000 Subject: [PATCH 04/26] declare strict mode in unit tests --- tests/Unit/Util/BasePathTest.php | 2 ++ tests/Unit/Util/CryptoTest.php | 2 ++ 2 files changed, 4 insertions(+) diff --git a/tests/Unit/Util/BasePathTest.php b/tests/Unit/Util/BasePathTest.php index e969f963af..10eb9e8e7a 100644 --- a/tests/Unit/Util/BasePathTest.php +++ b/tests/Unit/Util/BasePathTest.php @@ -5,6 +5,8 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later +declare(strict_types = 1); + namespace Friendica\Test\Unit\Util; use Friendica\Util\BasePath; diff --git a/tests/Unit/Util/CryptoTest.php b/tests/Unit/Util/CryptoTest.php index 1e728746f2..9dbffb29b4 100644 --- a/tests/Unit/Util/CryptoTest.php +++ b/tests/Unit/Util/CryptoTest.php @@ -5,6 +5,8 @@ // // SPDX-License-Identifier: AGPL-3.0-or-later +declare(strict_types = 1); + namespace Friendica\Test\Unit\Util; use Friendica\Util\Crypto; From a0e77032cff75b259f848af8d94690efab18a75d Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 13:34:10 +0000 Subject: [PATCH 05/26] remove $basepath from global namespace --- static/dependencies.config.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 035862f14d..335b7619e5 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -47,14 +47,13 @@ use Friendica\Network; use Friendica\Util; use Psr\Log\LoggerInterface; -/** - * @var string $basepath The base path of the Friendica installation without trailing slash - */ -$basepath = (function() { - return dirname(__FILE__, 2); -})(); +return (function(): array { + /** + * @var string $basepath The base path of the Friendica installation without trailing slash + */ + $basepath = dirname(__FILE__, 2); -return [ + return [ '*' => [ // marks all class result as shared for other creations, so there's just // one instance for the whole execution @@ -331,4 +330,5 @@ return [ $_GET['callback'] ?? '', ], ], -]; + ]; +})(); \ No newline at end of file From 3a491b879c243f8377d6ae0e8452fc2c72518427 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 13:35:46 +0000 Subject: [PATCH 06/26] Replace more calls of dirname() with $basepath --- static/dependencies.config.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 335b7619e5..7e11198232 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -72,13 +72,13 @@ return (function(): array { ['getPath', [], Dice::CHAIN_CALL], ], 'constructParams' => [ - dirname(__FILE__, 2), + $basepath, $_SERVER ] ], Util\BasePath::class => [ 'constructParams' => [ - dirname(__FILE__, 2), + $basepath, $_SERVER ] ], From 4deb28f24ef7f94c702006af1699247c39b53cae Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 13:40:53 +0000 Subject: [PATCH 07/26] Refactor DI::basePath() to use BasePath class --- src/DI.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/DI.php b/src/DI.php index de80da34d3..33976b9cfd 100644 --- a/src/DI.php +++ b/src/DI.php @@ -14,6 +14,7 @@ use Friendica\Core\Session\Capability\IHandleSessions; use Friendica\Core\Session\Capability\IHandleUserSessions; use Friendica\Navigation\SystemMessages; use Friendica\Protocol\ATProtocol; +use Friendica\Util\BasePath; use Psr\Log\LoggerInterface; /** @@ -756,7 +757,10 @@ abstract class DI */ public static function basePath() { - return self::$dice->create('$basepath'); + /** @var BasePath */ + $basePath = self::$dice->create(BasePath::class); + + return $basePath->getPath(); } /** From b9b44931acd6f71bf377d8c26f24f354017d11e0 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 13:42:01 +0000 Subject: [PATCH 08/26] Remove Dice rules for $basepath --- static/dependencies.config.php | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 7e11198232..b6a8b03cbc 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -66,16 +66,6 @@ return (function(): array { [Dice::INSTANCE => Dice::SELF], ], ], - '$basepath' => [ - 'instanceOf' => Util\BasePath::class, - 'call' => [ - ['getPath', [], Dice::CHAIN_CALL], - ], - 'constructParams' => [ - $basepath, - $_SERVER - ] - ], Util\BasePath::class => [ 'constructParams' => [ $basepath, From 4a766b9750983de003d2d23c8e8f391d5ed5b5e6 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:03:32 +0000 Subject: [PATCH 09/26] Replace class names with FQCN --- static/dependencies.config.php | 47 +++++++++++++++------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index b6a8b03cbc..59d8caa944 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -22,15 +22,10 @@ */ use Dice\Dice; -use Friendica\App; -use Friendica\AppHelper; -use Friendica\AppLegacy; -use Friendica\Core\Cache; use Friendica\Core\Config; use Friendica\Core\Hooks\Capability\ICanCreateInstances; use Friendica\Core\Hooks\Capability\ICanRegisterStrategies; use Friendica\Core\Hooks\Model\DiceInstanceManager; -use Friendica\Core\PConfig; use Friendica\Core\L10n; use Friendica\Core\Lock; use Friendica\Core\Session\Capability\IHandleSessions; @@ -39,13 +34,11 @@ use Friendica\Core\Storage\Repository\StorageManager; use Friendica\Database\Database; use Friendica\Database\Definition\DbaDefinition; use Friendica\Database\Definition\ViewDefinition; -use Friendica\Factory; use Friendica\Core\Storage\Capability\ICanWriteToStorage; use Friendica\Model\User\Cookie; use Friendica\Model\Log\ParsedLogIterator; use Friendica\Network; use Friendica\Util; -use Psr\Log\LoggerInterface; return (function(): array { /** @@ -91,8 +84,8 @@ return (function(): array { [Dice::INSTANCE => Dice::SELF], ], ], - AppHelper::class => [ - 'instanceOf' => AppLegacy::class, + \Friendica\AppHelper::class => [ + 'instanceOf' => \Friendica\AppLegacy::class, ], ICanCreateInstances::class => [ 'instanceOf' => DiceInstanceManager::class, @@ -115,7 +108,7 @@ return (function(): array { ['createCache', [], Dice::CHAIN_CALL], ], ], - App\Mode::class => [ + \Friendica\App\Mode::class => [ 'call' => [ ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL], ['determine', [ @@ -129,8 +122,8 @@ return (function(): array { $_SERVER, ], ], - PConfig\Capability\IManagePersonalConfigValues::class => [ - 'instanceOf' => PConfig\Factory\PConfig::class, + \Friendica\Core\PConfig\Capability\IManagePersonalConfigValues::class => [ + 'instanceOf' => \Friendica\Core\PConfig\Factory\PConfig::class, 'call' => [ ['create', [], Dice::CHAIN_CALL], ] @@ -157,18 +150,18 @@ return (function(): array { ], ], /** - * Creates the App\BaseURL + * Creates the \Friendica\App\BaseURL * * Same as: - * $baseURL = new App\BaseURL($configuration, $_SERVER); + * $baseURL = new \Friendica\App\BaseURL($configuration, $_SERVER); */ - App\BaseURL::class => [ + \Friendica\App\BaseURL::class => [ 'constructParams' => [ $_SERVER, ], ], '$hostname' => [ - 'instanceOf' => App\BaseURL::class, + 'instanceOf' => \Friendica\App\BaseURL::class, 'constructParams' => [ $_SERVER, ], @@ -176,12 +169,12 @@ return (function(): array { ['getHost', [], Dice::CHAIN_CALL], ], ], - Cache\Type\AbstractCache::class => [ + \Friendica\Core\Cache\Type\AbstractCache::class => [ 'constructParams' => [ [Dice::INSTANCE => '$hostname'], ], ], - App\Page::class => [ + \Friendica\App\Page::class => [ 'constructParams' => [ $basepath, ], @@ -216,14 +209,14 @@ return (function(): array { ['createDev', [], Dice::CHAIN_CALL], ], ], - Cache\Capability\ICanCache::class => [ - 'instanceOf' => Cache\Factory\Cache::class, + \Friendica\Core\Cache\Capability\ICanCache::class => [ + 'instanceOf' => \Friendica\Core\Cache\Factory\Cache::class, 'call' => [ ['createLocal', [], Dice::CHAIN_CALL], ], ], - Cache\Capability\ICanCacheInMemory::class => [ - 'instanceOf' => Cache\Factory\Cache::class, + \Friendica\Core\Cache\Capability\ICanCacheInMemory::class => [ + 'instanceOf' => \Friendica\Core\Cache\Factory\Cache::class, 'call' => [ ['createLocal', [], Dice::CHAIN_CALL], ], @@ -234,8 +227,8 @@ return (function(): array { ['create', [], Dice::CHAIN_CALL], ], ], - App\Arguments::class => [ - 'instanceOf' => App\Arguments::class, + \Friendica\App\Arguments::class => [ + 'instanceOf' => \Friendica\App\Arguments::class, 'call' => [ ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL], ], @@ -245,7 +238,7 @@ return (function(): array { $basepath, ], ], - App\Router::class => [ + \Friendica\App\Router::class => [ 'constructParams' => [ $_SERVER, __DIR__ . '/routes.config.php', @@ -301,7 +294,7 @@ return (function(): array { $_SERVER ], ], - App\Request::class => [ + \Friendica\App\Request::class => [ 'constructParams' => [ $_SERVER ], @@ -321,4 +314,4 @@ return (function(): array { ], ], ]; -})(); \ No newline at end of file +})(); From f1405cdb6c5bc643c13dc2a18997f0e6787085a9 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:06:04 +0000 Subject: [PATCH 10/26] Replace Config class names with FQCN --- static/dependencies.config.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 59d8caa944..29cee155ba 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -22,7 +22,6 @@ */ use Dice\Dice; -use Friendica\Core\Config; use Friendica\Core\Hooks\Capability\ICanCreateInstances; use Friendica\Core\Hooks\Capability\ICanRegisterStrategies; use Friendica\Core\Hooks\Model\DiceInstanceManager; @@ -93,8 +92,8 @@ return (function(): array { [Dice::INSTANCE => Dice::SELF], ], ], - Config\Util\ConfigFileManager::class => [ - 'instanceOf' => Config\Factory\Config::class, + \Friendica\Core\Config\Util\ConfigFileManager::class => [ + 'instanceOf' => \Friendica\Core\Config\Factory\Config::class, 'call' => [ ['createConfigFileManager', [ $basepath, @@ -102,8 +101,8 @@ return (function(): array { ], Dice::CHAIN_CALL], ], ], - Config\ValueObject\Cache::class => [ - 'instanceOf' => Config\Factory\Config::class, + \Friendica\Core\Config\ValueObject\Cache::class => [ + 'instanceOf' => \Friendica\Core\Config\Factory\Config::class, 'call' => [ ['createCache', [], Dice::CHAIN_CALL], ], @@ -116,8 +115,8 @@ return (function(): array { ], Dice::CHAIN_CALL], ], ], - Config\Capability\IManageConfigValues::class => [ - 'instanceOf' => Config\Model\DatabaseConfig::class, + \Friendica\Core\Config\Capability\IManageConfigValues::class => [ + 'instanceOf' => \Friendica\Core\Config\Model\DatabaseConfig::class, 'constructParams' => [ $_SERVER, ], @@ -146,7 +145,7 @@ return (function(): array { ], Database::class => [ 'constructParams' => [ - [Dice::INSTANCE => Config\Model\ReadOnlyFileConfig::class], + [Dice::INSTANCE => \Friendica\Core\Config\Model\ReadOnlyFileConfig::class], ], ], /** From 5803c1e760414f36773e0ec6d9bc7bb7b70beee0 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:11:40 +0000 Subject: [PATCH 11/26] Replace Hooks class names with FQCN --- static/dependencies.config.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 29cee155ba..8a982c15fb 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -22,8 +22,6 @@ */ use Dice\Dice; -use Friendica\Core\Hooks\Capability\ICanCreateInstances; -use Friendica\Core\Hooks\Capability\ICanRegisterStrategies; use Friendica\Core\Hooks\Model\DiceInstanceManager; use Friendica\Core\L10n; use Friendica\Core\Lock; @@ -77,7 +75,7 @@ return (function(): array { ['loadConfig'], ], ], - ICanRegisterStrategies::class => [ + \Friendica\Core\Hooks\Capability\ICanRegisterStrategies::class => [ 'instanceOf' => DiceInstanceManager::class, 'constructParams' => [ [Dice::INSTANCE => Dice::SELF], @@ -86,7 +84,7 @@ return (function(): array { \Friendica\AppHelper::class => [ 'instanceOf' => \Friendica\AppLegacy::class, ], - ICanCreateInstances::class => [ + \Friendica\Core\Hooks\Capability\ICanCreateInstances::class => [ 'instanceOf' => DiceInstanceManager::class, 'constructParams' => [ [Dice::INSTANCE => Dice::SELF], From c53a75bc3807543323b84d40dfd4e088904c30b1 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:12:37 +0000 Subject: [PATCH 12/26] Refactor dependency for $_SERVER --- static/dependencies.config.php | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 8a982c15fb..a7c2862005 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -37,7 +37,7 @@ use Friendica\Model\Log\ParsedLogIterator; use Friendica\Network; use Friendica\Util; -return (function(): array { +return (function(array $serverVars): array { /** * @var string $basepath The base path of the Friendica installation without trailing slash */ @@ -59,7 +59,7 @@ return (function(): array { Util\BasePath::class => [ 'constructParams' => [ $basepath, - $_SERVER + $serverVars, ] ], DiceInstanceManager::class => [ @@ -95,7 +95,7 @@ return (function(): array { 'call' => [ ['createConfigFileManager', [ $basepath, - $_SERVER, + $serverVars, ], Dice::CHAIN_CALL], ], ], @@ -107,7 +107,7 @@ return (function(): array { ], \Friendica\App\Mode::class => [ 'call' => [ - ['determineRunMode', [true, $_SERVER], Dice::CHAIN_CALL], + ['determineRunMode', [true, $serverVars], Dice::CHAIN_CALL], ['determine', [ $basepath, ], Dice::CHAIN_CALL], @@ -116,7 +116,7 @@ return (function(): array { \Friendica\Core\Config\Capability\IManageConfigValues::class => [ 'instanceOf' => \Friendica\Core\Config\Model\DatabaseConfig::class, 'constructParams' => [ - $_SERVER, + $serverVars, ], ], \Friendica\Core\PConfig\Capability\IManagePersonalConfigValues::class => [ @@ -154,13 +154,13 @@ return (function(): array { */ \Friendica\App\BaseURL::class => [ 'constructParams' => [ - $_SERVER, + $serverVars, ], ], '$hostname' => [ 'instanceOf' => \Friendica\App\BaseURL::class, 'constructParams' => [ - $_SERVER, + $serverVars, ], 'call' => [ ['getHost', [], Dice::CHAIN_CALL], @@ -227,7 +227,7 @@ return (function(): array { \Friendica\App\Arguments::class => [ 'instanceOf' => \Friendica\App\Arguments::class, 'call' => [ - ['determine', [$_SERVER, $_GET], Dice::CHAIN_CALL], + ['determine', [$serverVars, $_GET], Dice::CHAIN_CALL], ], ], \Friendica\Core\System::class => [ @@ -237,7 +237,7 @@ return (function(): array { ], \Friendica\App\Router::class => [ 'constructParams' => [ - $_SERVER, + $serverVars, __DIR__ . '/routes.config.php', [Dice::INSTANCE => Dice::SELF], null @@ -245,13 +245,13 @@ return (function(): array { ], L10n::class => [ 'constructParams' => [ - $_SERVER, $_GET + $serverVars, $_GET ], ], IHandleSessions::class => [ 'instanceOf' => \Friendica\Core\Session\Factory\Session::class, 'call' => [ - ['create', [$_SERVER], Dice::CHAIN_CALL], + ['create', [$serverVars], Dice::CHAIN_CALL], ['start', [], Dice::CHAIN_CALL], ], ], @@ -288,12 +288,12 @@ return (function(): array { ], \Friendica\Core\Worker\Repository\Process::class => [ 'constructParams' => [ - $_SERVER + $serverVars ], ], \Friendica\App\Request::class => [ 'constructParams' => [ - $_SERVER + $serverVars ], ], \Psr\Clock\ClockInterface::class => [ @@ -301,14 +301,14 @@ return (function(): array { ], \Friendica\Module\Special\HTTPException::class => [ 'constructParams' => [ - $_SERVER + $serverVars ], ], \Friendica\Module\Api\ApiResponse::class => [ 'constructParams' => [ - $_SERVER, + $serverVars, $_GET['callback'] ?? '', ], ], ]; -})(); +})($_SERVER); From 758751749938f3c976b185ad7632c37d5adcc9a0 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:18:22 +0000 Subject: [PATCH 13/26] Refactor dependency for $_GET --- static/dependencies.config.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index a7c2862005..54cd504e3c 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -37,7 +37,7 @@ use Friendica\Model\Log\ParsedLogIterator; use Friendica\Network; use Friendica\Util; -return (function(array $serverVars): array { +return (function(array $getVars, array $serverVars): array { /** * @var string $basepath The base path of the Friendica installation without trailing slash */ @@ -150,7 +150,7 @@ return (function(array $serverVars): array { * Creates the \Friendica\App\BaseURL * * Same as: - * $baseURL = new \Friendica\App\BaseURL($configuration, $_SERVER); + * $baseURL = new \Friendica\App\BaseURL($configuration, $); */ \Friendica\App\BaseURL::class => [ 'constructParams' => [ @@ -227,7 +227,7 @@ return (function(array $serverVars): array { \Friendica\App\Arguments::class => [ 'instanceOf' => \Friendica\App\Arguments::class, 'call' => [ - ['determine', [$serverVars, $_GET], Dice::CHAIN_CALL], + ['determine', [$serverVars, $getVars], Dice::CHAIN_CALL], ], ], \Friendica\Core\System::class => [ @@ -245,7 +245,7 @@ return (function(array $serverVars): array { ], L10n::class => [ 'constructParams' => [ - $serverVars, $_GET + $serverVars, $getVars ], ], IHandleSessions::class => [ @@ -307,8 +307,8 @@ return (function(array $serverVars): array { \Friendica\Module\Api\ApiResponse::class => [ 'constructParams' => [ $serverVars, - $_GET['callback'] ?? '', + $getVars['callback'] ?? '', ], ], ]; -})($_SERVER); +})($_GET, $_SERVER); From b4762238ed3a6c3b4a5455a93ec712b066e92725 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:19:31 +0000 Subject: [PATCH 14/26] Replace DiceInstanceManager class names with FQCN --- static/dependencies.config.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 54cd504e3c..60a63ff634 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -22,7 +22,6 @@ */ use Dice\Dice; -use Friendica\Core\Hooks\Model\DiceInstanceManager; use Friendica\Core\L10n; use Friendica\Core\Lock; use Friendica\Core\Session\Capability\IHandleSessions; @@ -62,7 +61,7 @@ return (function(array $getVars, array $serverVars): array { $serverVars, ] ], - DiceInstanceManager::class => [ + \Friendica\Core\Hooks\Model\DiceInstanceManager::class => [ 'constructParams' => [ [Dice::INSTANCE => Dice::SELF], ] @@ -76,7 +75,7 @@ return (function(array $getVars, array $serverVars): array { ], ], \Friendica\Core\Hooks\Capability\ICanRegisterStrategies::class => [ - 'instanceOf' => DiceInstanceManager::class, + 'instanceOf' => \Friendica\Core\Hooks\Model\DiceInstanceManager::class, 'constructParams' => [ [Dice::INSTANCE => Dice::SELF], ], @@ -85,7 +84,7 @@ return (function(array $getVars, array $serverVars): array { 'instanceOf' => \Friendica\AppLegacy::class, ], \Friendica\Core\Hooks\Capability\ICanCreateInstances::class => [ - 'instanceOf' => DiceInstanceManager::class, + 'instanceOf' => \Friendica\Core\Hooks\Model\DiceInstanceManager::class, 'constructParams' => [ [Dice::INSTANCE => Dice::SELF], ], From 48bd6b2f8160637820387e8153e57d417c01aa81 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:22:52 +0000 Subject: [PATCH 15/26] Refactor dependency for $basepath --- static/dependencies.config.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 60a63ff634..67c7194c30 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -36,12 +36,10 @@ use Friendica\Model\Log\ParsedLogIterator; use Friendica\Network; use Friendica\Util; -return (function(array $getVars, array $serverVars): array { - /** - * @var string $basepath The base path of the Friendica installation without trailing slash - */ - $basepath = dirname(__FILE__, 2); - +/** + * @param string $basepath The base path of the Friendica installation without trailing slash + */ +return (function(string $basepath, array $getVars, array $serverVars): array { return [ '*' => [ // marks all class result as shared for other creations, so there's just @@ -310,4 +308,8 @@ return (function(array $getVars, array $serverVars): array { ], ], ]; -})($_GET, $_SERVER); +})( + dirname(__FILE__, 2), + $_GET, + $_SERVER +); From 31a731deb7cc65e303d92e82d77ddad8265bbad2 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:23:58 +0000 Subject: [PATCH 16/26] Refactor dependency for $_COOKIE --- static/dependencies.config.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 67c7194c30..1ead393f48 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -39,7 +39,7 @@ use Friendica\Util; /** * @param string $basepath The base path of the Friendica installation without trailing slash */ -return (function(string $basepath, array $getVars, array $serverVars): array { +return (function(string $basepath, array $getVars, array $serverVars, array $cookieVars): array { return [ '*' => [ // marks all class result as shared for other creations, so there's just @@ -257,7 +257,7 @@ return (function(string $basepath, array $getVars, array $serverVars): array { ], Cookie::class => [ 'constructParams' => [ - $_COOKIE + $cookieVars, ], ], ICanWriteToStorage::class => [ @@ -311,5 +311,6 @@ return (function(string $basepath, array $getVars, array $serverVars): array { })( dirname(__FILE__, 2), $_GET, - $_SERVER + $_SERVER, + $_COOKIE ); From 5edc36d6fc78c1d1d212b1b567935e648a46e0d7 Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:28:01 +0000 Subject: [PATCH 17/26] Fix PHPDoc and add link to DICE docs --- static/dependencies.config.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 1ead393f48..8d76e79a68 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -1,10 +1,11 @@ Date: Mon, 23 Dec 2024 14:30:14 +0000 Subject: [PATCH 18/26] Replace Core class names with FQCN --- static/dependencies.config.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 8d76e79a68..8e9b8e5c16 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -24,11 +24,6 @@ */ use Dice\Dice; -use Friendica\Core\L10n; -use Friendica\Core\Lock; -use Friendica\Core\Session\Capability\IHandleSessions; -use Friendica\Core\Session\Capability\IHandleUserSessions; -use Friendica\Core\Storage\Repository\StorageManager; use Friendica\Database\Database; use Friendica\Database\Definition\DbaDefinition; use Friendica\Database\Definition\ViewDefinition; @@ -217,8 +212,8 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ['createLocal', [], Dice::CHAIN_CALL], ], ], - Lock\Capability\ICanLock::class => [ - 'instanceOf' => Lock\Factory\Lock::class, + \Friendica\Core\Lock\Capability\ICanLock::class => [ + 'instanceOf' => \Friendica\Core\Lock\Factory\Lock::class, 'call' => [ ['create', [], Dice::CHAIN_CALL], ], @@ -242,19 +237,19 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo null ], ], - L10n::class => [ + \Friendica\Core\L10n::class => [ 'constructParams' => [ $serverVars, $getVars ], ], - IHandleSessions::class => [ + \Friendica\Core\Session\Capability\IHandleSessions::class => [ 'instanceOf' => \Friendica\Core\Session\Factory\Session::class, 'call' => [ ['create', [$serverVars], Dice::CHAIN_CALL], ['start', [], Dice::CHAIN_CALL], ], ], - IHandleUserSessions::class => [ + \Friendica\Core\Session\Capability\IHandleUserSessions::class => [ 'instanceOf' => \Friendica\Core\Session\Model\UserSession::class, ], Cookie::class => [ @@ -263,7 +258,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ], ], ICanWriteToStorage::class => [ - 'instanceOf' => StorageManager::class, + 'instanceOf' => \Friendica\Core\Storage\Repository\StorageManager::class, 'call' => [ ['getBackend', [], Dice::CHAIN_CALL], ], From c33223a0ebf79e4ff79d077ca98b2476809ed53a Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:31:41 +0000 Subject: [PATCH 19/26] Replace Database class names with FQCN --- static/dependencies.config.php | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 8e9b8e5c16..7a37d5e8bc 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -24,10 +24,6 @@ */ use Dice\Dice; -use Friendica\Database\Database; -use Friendica\Database\Definition\DbaDefinition; -use Friendica\Database\Definition\ViewDefinition; -use Friendica\Core\Storage\Capability\ICanWriteToStorage; use Friendica\Model\User\Cookie; use Friendica\Model\Log\ParsedLogIterator; use Friendica\Network; @@ -119,7 +115,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ['create', [], Dice::CHAIN_CALL], ] ], - DbaDefinition::class => [ + \Friendica\Database\Definition\DbaDefinition::class => [ 'constructParams' => [ $basepath, ], @@ -127,7 +123,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ['load', [false], Dice::CHAIN_CALL], ], ], - ViewDefinition::class => [ + \Friendica\Database\Definition\ViewDefinition::class => [ 'constructParams' => [ $basepath, ], @@ -135,7 +131,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ['load', [false], Dice::CHAIN_CALL], ], ], - Database::class => [ + \Friendica\Database\Database::class => [ 'constructParams' => [ [Dice::INSTANCE => \Friendica\Core\Config\Model\ReadOnlyFileConfig::class], ], @@ -257,7 +253,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo $cookieVars, ], ], - ICanWriteToStorage::class => [ + \Friendica\Core\Storage\Capability\ICanWriteToStorage::class => [ 'instanceOf' => \Friendica\Core\Storage\Repository\StorageManager::class, 'call' => [ ['getBackend', [], Dice::CHAIN_CALL], From 011c098c6316b9fa06a734fe0d0e164e95efeedc Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:32:47 +0000 Subject: [PATCH 20/26] Replace Model class names with FQCN --- static/dependencies.config.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 7a37d5e8bc..437307e599 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -24,8 +24,6 @@ */ use Dice\Dice; -use Friendica\Model\User\Cookie; -use Friendica\Model\Log\ParsedLogIterator; use Friendica\Network; use Friendica\Util; @@ -248,7 +246,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo \Friendica\Core\Session\Capability\IHandleUserSessions::class => [ 'instanceOf' => \Friendica\Core\Session\Model\UserSession::class, ], - Cookie::class => [ + \Friendica\Model\User\Cookie::class => [ 'constructParams' => [ $cookieVars, ], @@ -271,7 +269,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ['createClient', [], Dice::CHAIN_CALL], ], ], - ParsedLogIterator::class => [ + \Friendica\Model\Log\ParsedLogIterator::class => [ 'constructParams' => [ [Dice::INSTANCE => Util\ReversedFileReader::class], ] From 899ac663fc46dba52aea5cb70e75ba583524f32f Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:34:23 +0000 Subject: [PATCH 21/26] Replace Network class names with FQCN --- static/dependencies.config.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 437307e599..4840996d26 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -24,7 +24,6 @@ */ use Dice\Dice; -use Friendica\Network; use Friendica\Util; /** @@ -263,8 +262,8 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ['create', [], Dice::CHAIN_CALL], ], ], - Network\HTTPClient\Capability\ICanSendHttpRequests::class => [ - 'instanceOf' => Network\HTTPClient\Factory\HttpClient::class, + \Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests::class => [ + 'instanceOf' => \Friendica\Network\HTTPClient\Factory\HttpClient::class, 'call' => [ ['createClient', [], Dice::CHAIN_CALL], ], From dd4fbc0194b23ba06c1ed7a54eb29ab49329a6ef Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:34:57 +0000 Subject: [PATCH 22/26] Replace Util class names with FQCN --- static/dependencies.config.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 4840996d26..d3126b9b26 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -24,7 +24,6 @@ */ use Dice\Dice; -use Friendica\Util; /** * @param string $basepath The base path of the Friendica installation without trailing slash @@ -43,7 +42,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo [Dice::INSTANCE => Dice::SELF], ], ], - Util\BasePath::class => [ + \Friendica\Util\BasePath::class => [ 'constructParams' => [ $basepath, $serverVars, @@ -270,7 +269,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ], \Friendica\Model\Log\ParsedLogIterator::class => [ 'constructParams' => [ - [Dice::INSTANCE => Util\ReversedFileReader::class], + [Dice::INSTANCE => \Friendica\Util\ReversedFileReader::class], ] ], \Friendica\Core\Worker\Repository\Process::class => [ @@ -284,7 +283,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ], ], \Psr\Clock\ClockInterface::class => [ - 'instanceOf' => Util\Clock\SystemClock::class + 'instanceOf' => \Friendica\Util\Clock\SystemClock::class ], \Friendica\Module\Special\HTTPException::class => [ 'constructParams' => [ From 0bd8118673edf84255f5ac934276cd83608fea2d Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:51:41 +0000 Subject: [PATCH 23/26] Fix code style --- static/dependencies.config.php | 48 +++++++++++++++++----------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index d3126b9b26..64c67cbc15 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -30,7 +30,7 @@ use Dice\Dice; */ return (function(string $basepath, array $getVars, array $serverVars, array $cookieVars): array { return [ - '*' => [ + '*' => [ // marks all class result as shared for other creations, so there's just // one instance for the whole execution 'shared' => true, @@ -42,13 +42,13 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo [Dice::INSTANCE => Dice::SELF], ], ], - \Friendica\Util\BasePath::class => [ + \Friendica\Util\BasePath::class => [ 'constructParams' => [ $basepath, $serverVars, ] ], - \Friendica\Core\Hooks\Model\DiceInstanceManager::class => [ + \Friendica\Core\Hooks\Model\DiceInstanceManager::class => [ 'constructParams' => [ [Dice::INSTANCE => Dice::SELF], ] @@ -70,7 +70,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo \Friendica\AppHelper::class => [ 'instanceOf' => \Friendica\AppLegacy::class, ], - \Friendica\Core\Hooks\Capability\ICanCreateInstances::class => [ + \Friendica\Core\Hooks\Capability\ICanCreateInstances::class => [ 'instanceOf' => \Friendica\Core\Hooks\Model\DiceInstanceManager::class, 'constructParams' => [ [Dice::INSTANCE => Dice::SELF], @@ -78,7 +78,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ], \Friendica\Core\Config\Util\ConfigFileManager::class => [ 'instanceOf' => \Friendica\Core\Config\Factory\Config::class, - 'call' => [ + 'call' => [ ['createConfigFileManager', [ $basepath, $serverVars, @@ -87,11 +87,11 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ], \Friendica\Core\Config\ValueObject\Cache::class => [ 'instanceOf' => \Friendica\Core\Config\Factory\Config::class, - 'call' => [ + 'call' => [ ['createCache', [], Dice::CHAIN_CALL], ], ], - \Friendica\App\Mode::class => [ + \Friendica\App\Mode::class => [ 'call' => [ ['determineRunMode', [true, $serverVars], Dice::CHAIN_CALL], ['determine', [ @@ -107,7 +107,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ], \Friendica\Core\PConfig\Capability\IManagePersonalConfigValues::class => [ 'instanceOf' => \Friendica\Core\PConfig\Factory\PConfig::class, - 'call' => [ + 'call' => [ ['create', [], Dice::CHAIN_CALL], ] ], @@ -127,7 +127,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ['load', [false], Dice::CHAIN_CALL], ], ], - \Friendica\Database\Database::class => [ + \Friendica\Database\Database::class => [ 'constructParams' => [ [Dice::INSTANCE => \Friendica\Core\Config\Model\ReadOnlyFileConfig::class], ], @@ -138,12 +138,12 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo * Same as: * $baseURL = new \Friendica\App\BaseURL($configuration, $); */ - \Friendica\App\BaseURL::class => [ + \Friendica\App\BaseURL::class => [ 'constructParams' => [ $serverVars, ], ], - '$hostname' => [ + '$hostname' => [ 'instanceOf' => \Friendica\App\BaseURL::class, 'constructParams' => [ $serverVars, @@ -162,51 +162,51 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo $basepath, ], ], - \Psr\Log\LoggerInterface::class => [ + \Psr\Log\LoggerInterface::class => [ 'instanceOf' => \Friendica\Core\Logger\Factory\Logger::class, - 'call' => [ + 'call' => [ ['create', [], Dice::CHAIN_CALL], ], ], - \Friendica\Core\Logger\Type\SyslogLogger::class => [ + \Friendica\Core\Logger\Type\SyslogLogger::class => [ 'instanceOf' => \Friendica\Core\Logger\Factory\SyslogLogger::class, - 'call' => [ + 'call' => [ ['create', [], Dice::CHAIN_CALL], ], ], - \Friendica\Core\Logger\Type\StreamLogger::class => [ + \Friendica\Core\Logger\Type\StreamLogger::class => [ 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class, - 'call' => [ + 'call' => [ ['create', [], Dice::CHAIN_CALL], ], ], \Friendica\Core\Logger\Capability\IHaveCallIntrospections::class => [ - 'instanceOf' => \Friendica\Core\Logger\Util\Introspection::class, + 'instanceOf' => \Friendica\Core\Logger\Util\Introspection::class, 'constructParams' => [ \Friendica\Core\Logger\Capability\IHaveCallIntrospections::IGNORE_CLASS_LIST, ], ], - '$devLogger' => [ + '$devLogger' => [ 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class, - 'call' => [ + 'call' => [ ['createDev', [], Dice::CHAIN_CALL], ], ], \Friendica\Core\Cache\Capability\ICanCache::class => [ 'instanceOf' => \Friendica\Core\Cache\Factory\Cache::class, - 'call' => [ + 'call' => [ ['createLocal', [], Dice::CHAIN_CALL], ], ], \Friendica\Core\Cache\Capability\ICanCacheInMemory::class => [ 'instanceOf' => \Friendica\Core\Cache\Factory\Cache::class, - 'call' => [ + 'call' => [ ['createLocal', [], Dice::CHAIN_CALL], ], ], \Friendica\Core\Lock\Capability\ICanLock::class => [ 'instanceOf' => \Friendica\Core\Lock\Factory\Lock::class, - 'call' => [ + 'call' => [ ['create', [], Dice::CHAIN_CALL], ], ], @@ -263,7 +263,7 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo ], \Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests::class => [ 'instanceOf' => \Friendica\Network\HTTPClient\Factory\HttpClient::class, - 'call' => [ + 'call' => [ ['createClient', [], Dice::CHAIN_CALL], ], ], From ae0cab36dc8d981e8beaf039c11aba4065a9c4ca Mon Sep 17 00:00:00 2001 From: Art4 Date: Mon, 23 Dec 2024 14:51:58 +0000 Subject: [PATCH 24/26] Improve BasePath tests --- tests/Unit/Util/BasePathTest.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/Unit/Util/BasePathTest.php b/tests/Unit/Util/BasePathTest.php index 10eb9e8e7a..26c495b7fe 100644 --- a/tests/Unit/Util/BasePathTest.php +++ b/tests/Unit/Util/BasePathTest.php @@ -16,46 +16,49 @@ class BasePathTest extends TestCase { public static function getDataPaths(): array { + $basePath = dirname(__DIR__, 3); + $configPath = $basePath . DIRECTORY_SEPARATOR . 'config'; + return [ 'fullPath' => [ 'server' => [], - 'baseDir' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', - 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + 'baseDir' => $configPath, + 'expected' => $configPath, ], 'relative' => [ 'server' => [], 'baseDir' => 'config', - 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + 'expected' => $configPath, ], 'document_root' => [ 'server' => [ - 'DOCUMENT_ROOT' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + 'DOCUMENT_ROOT' => $configPath, ], 'baseDir' => '/noooop', - 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + 'expected' => $configPath, ], 'pwd' => [ 'server' => [ - 'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + 'PWD' => $configPath, ], 'baseDir' => '/noooop', - 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + 'expected' => $configPath, ], 'no_overwrite' => [ 'server' => [ - 'DOCUMENT_ROOT' => dirname(__DIR__, 3), - 'PWD' => dirname(__DIR__, 3), + 'DOCUMENT_ROOT' => $basePath, + 'PWD' => $basePath, ], 'baseDir' => 'config', - 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + 'expected' => $configPath, ], 'no_overwrite_if_invalid' => [ 'server' => [ 'DOCUMENT_ROOT' => '/nopopop', - 'PWD' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + 'PWD' => $configPath, ], 'baseDir' => '/noatgawe22fafa', - 'expected' => dirname(__DIR__, 3) . DIRECTORY_SEPARATOR . 'config', + 'expected' => $configPath, ] ]; } From ed06480e750eaac12e4d77e926bc5325e41810a1 Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 26 Dec 2024 07:00:21 +0000 Subject: [PATCH 25/26] Remove comment --- static/dependencies.config.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 64c67cbc15..bd850bd1c7 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -132,12 +132,6 @@ return (function(string $basepath, array $getVars, array $serverVars, array $coo [Dice::INSTANCE => \Friendica\Core\Config\Model\ReadOnlyFileConfig::class], ], ], - /** - * Creates the \Friendica\App\BaseURL - * - * Same as: - * $baseURL = new \Friendica\App\BaseURL($configuration, $); - */ \Friendica\App\BaseURL::class => [ 'constructParams' => [ $serverVars, From 962a76759f795fede3a51cecb432c73983e875ad Mon Sep 17 00:00:00 2001 From: Art4 Date: Thu, 26 Dec 2024 18:36:40 +0000 Subject: [PATCH 26/26] Fix indentation --- static/dependencies.config.php | 440 ++++++++++++++++----------------- 1 file changed, 220 insertions(+), 220 deletions(-) diff --git a/static/dependencies.config.php b/static/dependencies.config.php index bd850bd1c7..93d9de81ac 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -30,266 +30,266 @@ use Dice\Dice; */ return (function(string $basepath, array $getVars, array $serverVars, array $cookieVars): array { return [ - '*' => [ - // marks all class result as shared for other creations, so there's just - // one instance for the whole execution - 'shared' => true, - ], - \Friendica\Core\Addon\Capability\ICanLoadAddons::class => [ - 'instanceOf' => \Friendica\Core\Addon\Model\AddonLoader::class, - 'constructParams' => [ - $basepath, - [Dice::INSTANCE => Dice::SELF], + '*' => [ + // marks all class result as shared for other creations, so there's just + // one instance for the whole execution + 'shared' => true, ], - ], - \Friendica\Util\BasePath::class => [ - 'constructParams' => [ - $basepath, - $serverVars, - ] - ], - \Friendica\Core\Hooks\Model\DiceInstanceManager::class => [ - 'constructParams' => [ - [Dice::INSTANCE => Dice::SELF], - ] - ], - \Friendica\Core\Hooks\Util\StrategiesFileManager::class => [ - 'constructParams' => [ - $basepath, + \Friendica\Core\Addon\Capability\ICanLoadAddons::class => [ + 'instanceOf' => \Friendica\Core\Addon\Model\AddonLoader::class, + 'constructParams' => [ + $basepath, + [Dice::INSTANCE => Dice::SELF], + ], ], - 'call' => [ - ['loadConfig'], - ], - ], - \Friendica\Core\Hooks\Capability\ICanRegisterStrategies::class => [ - 'instanceOf' => \Friendica\Core\Hooks\Model\DiceInstanceManager::class, - 'constructParams' => [ - [Dice::INSTANCE => Dice::SELF], - ], - ], - \Friendica\AppHelper::class => [ - 'instanceOf' => \Friendica\AppLegacy::class, - ], - \Friendica\Core\Hooks\Capability\ICanCreateInstances::class => [ - 'instanceOf' => \Friendica\Core\Hooks\Model\DiceInstanceManager::class, - 'constructParams' => [ - [Dice::INSTANCE => Dice::SELF], - ], - ], - \Friendica\Core\Config\Util\ConfigFileManager::class => [ - 'instanceOf' => \Friendica\Core\Config\Factory\Config::class, - 'call' => [ - ['createConfigFileManager', [ + \Friendica\Util\BasePath::class => [ + 'constructParams' => [ $basepath, $serverVars, - ], Dice::CHAIN_CALL], + ] ], - ], - \Friendica\Core\Config\ValueObject\Cache::class => [ - 'instanceOf' => \Friendica\Core\Config\Factory\Config::class, - 'call' => [ - ['createCache', [], Dice::CHAIN_CALL], + \Friendica\Core\Hooks\Model\DiceInstanceManager::class => [ + 'constructParams' => [ + [Dice::INSTANCE => Dice::SELF], + ] ], - ], - \Friendica\App\Mode::class => [ - 'call' => [ - ['determineRunMode', [true, $serverVars], Dice::CHAIN_CALL], - ['determine', [ + \Friendica\Core\Hooks\Util\StrategiesFileManager::class => [ + 'constructParams' => [ $basepath, - ], Dice::CHAIN_CALL], + ], + 'call' => [ + ['loadConfig'], + ], ], - ], - \Friendica\Core\Config\Capability\IManageConfigValues::class => [ - 'instanceOf' => \Friendica\Core\Config\Model\DatabaseConfig::class, - 'constructParams' => [ - $serverVars, + \Friendica\Core\Hooks\Capability\ICanRegisterStrategies::class => [ + 'instanceOf' => \Friendica\Core\Hooks\Model\DiceInstanceManager::class, + 'constructParams' => [ + [Dice::INSTANCE => Dice::SELF], + ], ], - ], - \Friendica\Core\PConfig\Capability\IManagePersonalConfigValues::class => [ - 'instanceOf' => \Friendica\Core\PConfig\Factory\PConfig::class, - 'call' => [ - ['create', [], Dice::CHAIN_CALL], - ] - ], - \Friendica\Database\Definition\DbaDefinition::class => [ - 'constructParams' => [ - $basepath, + \Friendica\AppHelper::class => [ + 'instanceOf' => \Friendica\AppLegacy::class, ], - 'call' => [ - ['load', [false], Dice::CHAIN_CALL], + \Friendica\Core\Hooks\Capability\ICanCreateInstances::class => [ + 'instanceOf' => \Friendica\Core\Hooks\Model\DiceInstanceManager::class, + 'constructParams' => [ + [Dice::INSTANCE => Dice::SELF], + ], ], - ], - \Friendica\Database\Definition\ViewDefinition::class => [ - 'constructParams' => [ - $basepath, + \Friendica\Core\Config\Util\ConfigFileManager::class => [ + 'instanceOf' => \Friendica\Core\Config\Factory\Config::class, + 'call' => [ + ['createConfigFileManager', [ + $basepath, + $serverVars, + ], Dice::CHAIN_CALL], + ], ], - 'call' => [ - ['load', [false], Dice::CHAIN_CALL], + \Friendica\Core\Config\ValueObject\Cache::class => [ + 'instanceOf' => \Friendica\Core\Config\Factory\Config::class, + 'call' => [ + ['createCache', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Database\Database::class => [ - 'constructParams' => [ - [Dice::INSTANCE => \Friendica\Core\Config\Model\ReadOnlyFileConfig::class], + \Friendica\App\Mode::class => [ + 'call' => [ + ['determineRunMode', [true, $serverVars], Dice::CHAIN_CALL], + ['determine', [ + $basepath, + ], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\App\BaseURL::class => [ - 'constructParams' => [ - $serverVars, + \Friendica\Core\Config\Capability\IManageConfigValues::class => [ + 'instanceOf' => \Friendica\Core\Config\Model\DatabaseConfig::class, + 'constructParams' => [ + $serverVars, + ], ], - ], - '$hostname' => [ - 'instanceOf' => \Friendica\App\BaseURL::class, - 'constructParams' => [ - $serverVars, + \Friendica\Core\PConfig\Capability\IManagePersonalConfigValues::class => [ + 'instanceOf' => \Friendica\Core\PConfig\Factory\PConfig::class, + 'call' => [ + ['create', [], Dice::CHAIN_CALL], + ] ], - 'call' => [ - ['getHost', [], Dice::CHAIN_CALL], + \Friendica\Database\Definition\DbaDefinition::class => [ + 'constructParams' => [ + $basepath, + ], + 'call' => [ + ['load', [false], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Core\Cache\Type\AbstractCache::class => [ - 'constructParams' => [ - [Dice::INSTANCE => '$hostname'], + \Friendica\Database\Definition\ViewDefinition::class => [ + 'constructParams' => [ + $basepath, + ], + 'call' => [ + ['load', [false], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\App\Page::class => [ - 'constructParams' => [ - $basepath, + \Friendica\Database\Database::class => [ + 'constructParams' => [ + [Dice::INSTANCE => \Friendica\Core\Config\Model\ReadOnlyFileConfig::class], + ], ], - ], - \Psr\Log\LoggerInterface::class => [ - 'instanceOf' => \Friendica\Core\Logger\Factory\Logger::class, - 'call' => [ - ['create', [], Dice::CHAIN_CALL], + \Friendica\App\BaseURL::class => [ + 'constructParams' => [ + $serverVars, + ], ], - ], - \Friendica\Core\Logger\Type\SyslogLogger::class => [ - 'instanceOf' => \Friendica\Core\Logger\Factory\SyslogLogger::class, - 'call' => [ - ['create', [], Dice::CHAIN_CALL], + '$hostname' => [ + 'instanceOf' => \Friendica\App\BaseURL::class, + 'constructParams' => [ + $serverVars, + ], + 'call' => [ + ['getHost', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Core\Logger\Type\StreamLogger::class => [ - 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class, - 'call' => [ - ['create', [], Dice::CHAIN_CALL], + \Friendica\Core\Cache\Type\AbstractCache::class => [ + 'constructParams' => [ + [Dice::INSTANCE => '$hostname'], + ], ], - ], - \Friendica\Core\Logger\Capability\IHaveCallIntrospections::class => [ - 'instanceOf' => \Friendica\Core\Logger\Util\Introspection::class, - 'constructParams' => [ - \Friendica\Core\Logger\Capability\IHaveCallIntrospections::IGNORE_CLASS_LIST, + \Friendica\App\Page::class => [ + 'constructParams' => [ + $basepath, + ], ], - ], - '$devLogger' => [ - 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class, - 'call' => [ - ['createDev', [], Dice::CHAIN_CALL], + \Psr\Log\LoggerInterface::class => [ + 'instanceOf' => \Friendica\Core\Logger\Factory\Logger::class, + 'call' => [ + ['create', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Core\Cache\Capability\ICanCache::class => [ - 'instanceOf' => \Friendica\Core\Cache\Factory\Cache::class, - 'call' => [ - ['createLocal', [], Dice::CHAIN_CALL], + \Friendica\Core\Logger\Type\SyslogLogger::class => [ + 'instanceOf' => \Friendica\Core\Logger\Factory\SyslogLogger::class, + 'call' => [ + ['create', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Core\Cache\Capability\ICanCacheInMemory::class => [ - 'instanceOf' => \Friendica\Core\Cache\Factory\Cache::class, - 'call' => [ - ['createLocal', [], Dice::CHAIN_CALL], + \Friendica\Core\Logger\Type\StreamLogger::class => [ + 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class, + 'call' => [ + ['create', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Core\Lock\Capability\ICanLock::class => [ - 'instanceOf' => \Friendica\Core\Lock\Factory\Lock::class, - 'call' => [ - ['create', [], Dice::CHAIN_CALL], + \Friendica\Core\Logger\Capability\IHaveCallIntrospections::class => [ + 'instanceOf' => \Friendica\Core\Logger\Util\Introspection::class, + 'constructParams' => [ + \Friendica\Core\Logger\Capability\IHaveCallIntrospections::IGNORE_CLASS_LIST, + ], ], - ], - \Friendica\App\Arguments::class => [ - 'instanceOf' => \Friendica\App\Arguments::class, - 'call' => [ - ['determine', [$serverVars, $getVars], Dice::CHAIN_CALL], + '$devLogger' => [ + 'instanceOf' => \Friendica\Core\Logger\Factory\StreamLogger::class, + 'call' => [ + ['createDev', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Core\System::class => [ - 'constructParams' => [ - $basepath, + \Friendica\Core\Cache\Capability\ICanCache::class => [ + 'instanceOf' => \Friendica\Core\Cache\Factory\Cache::class, + 'call' => [ + ['createLocal', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\App\Router::class => [ - 'constructParams' => [ - $serverVars, - __DIR__ . '/routes.config.php', - [Dice::INSTANCE => Dice::SELF], - null + \Friendica\Core\Cache\Capability\ICanCacheInMemory::class => [ + 'instanceOf' => \Friendica\Core\Cache\Factory\Cache::class, + 'call' => [ + ['createLocal', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Core\L10n::class => [ - 'constructParams' => [ - $serverVars, $getVars + \Friendica\Core\Lock\Capability\ICanLock::class => [ + 'instanceOf' => \Friendica\Core\Lock\Factory\Lock::class, + 'call' => [ + ['create', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Core\Session\Capability\IHandleSessions::class => [ - 'instanceOf' => \Friendica\Core\Session\Factory\Session::class, - 'call' => [ - ['create', [$serverVars], Dice::CHAIN_CALL], - ['start', [], Dice::CHAIN_CALL], + \Friendica\App\Arguments::class => [ + 'instanceOf' => \Friendica\App\Arguments::class, + 'call' => [ + ['determine', [$serverVars, $getVars], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Core\Session\Capability\IHandleUserSessions::class => [ - 'instanceOf' => \Friendica\Core\Session\Model\UserSession::class, - ], - \Friendica\Model\User\Cookie::class => [ - 'constructParams' => [ - $cookieVars, + \Friendica\Core\System::class => [ + 'constructParams' => [ + $basepath, + ], ], - ], - \Friendica\Core\Storage\Capability\ICanWriteToStorage::class => [ - 'instanceOf' => \Friendica\Core\Storage\Repository\StorageManager::class, - 'call' => [ - ['getBackend', [], Dice::CHAIN_CALL], + \Friendica\App\Router::class => [ + 'constructParams' => [ + $serverVars, + __DIR__ . '/routes.config.php', + [Dice::INSTANCE => Dice::SELF], + null + ], ], - ], - \Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs::class => [ - 'instanceOf' => \Friendica\Core\KeyValueStorage\Factory\KeyValueStorage::class, - 'call' => [ - ['create', [], Dice::CHAIN_CALL], + \Friendica\Core\L10n::class => [ + 'constructParams' => [ + $serverVars, $getVars + ], ], - ], - \Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests::class => [ - 'instanceOf' => \Friendica\Network\HTTPClient\Factory\HttpClient::class, - 'call' => [ - ['createClient', [], Dice::CHAIN_CALL], + \Friendica\Core\Session\Capability\IHandleSessions::class => [ + 'instanceOf' => \Friendica\Core\Session\Factory\Session::class, + 'call' => [ + ['create', [$serverVars], Dice::CHAIN_CALL], + ['start', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Model\Log\ParsedLogIterator::class => [ - 'constructParams' => [ - [Dice::INSTANCE => \Friendica\Util\ReversedFileReader::class], - ] - ], - \Friendica\Core\Worker\Repository\Process::class => [ - 'constructParams' => [ - $serverVars + \Friendica\Core\Session\Capability\IHandleUserSessions::class => [ + 'instanceOf' => \Friendica\Core\Session\Model\UserSession::class, ], - ], - \Friendica\App\Request::class => [ - 'constructParams' => [ - $serverVars + \Friendica\Model\User\Cookie::class => [ + 'constructParams' => [ + $cookieVars, + ], ], - ], - \Psr\Clock\ClockInterface::class => [ - 'instanceOf' => \Friendica\Util\Clock\SystemClock::class - ], - \Friendica\Module\Special\HTTPException::class => [ - 'constructParams' => [ - $serverVars + \Friendica\Core\Storage\Capability\ICanWriteToStorage::class => [ + 'instanceOf' => \Friendica\Core\Storage\Repository\StorageManager::class, + 'call' => [ + ['getBackend', [], Dice::CHAIN_CALL], + ], ], - ], - \Friendica\Module\Api\ApiResponse::class => [ - 'constructParams' => [ - $serverVars, - $getVars['callback'] ?? '', + \Friendica\Core\KeyValueStorage\Capability\IManageKeyValuePairs::class => [ + 'instanceOf' => \Friendica\Core\KeyValueStorage\Factory\KeyValueStorage::class, + 'call' => [ + ['create', [], Dice::CHAIN_CALL], + ], + ], + \Friendica\Network\HTTPClient\Capability\ICanSendHttpRequests::class => [ + 'instanceOf' => \Friendica\Network\HTTPClient\Factory\HttpClient::class, + 'call' => [ + ['createClient', [], Dice::CHAIN_CALL], + ], + ], + \Friendica\Model\Log\ParsedLogIterator::class => [ + 'constructParams' => [ + [Dice::INSTANCE => \Friendica\Util\ReversedFileReader::class], + ] + ], + \Friendica\Core\Worker\Repository\Process::class => [ + 'constructParams' => [ + $serverVars + ], + ], + \Friendica\App\Request::class => [ + 'constructParams' => [ + $serverVars + ], + ], + \Psr\Clock\ClockInterface::class => [ + 'instanceOf' => \Friendica\Util\Clock\SystemClock::class + ], + \Friendica\Module\Special\HTTPException::class => [ + 'constructParams' => [ + $serverVars + ], + ], + \Friendica\Module\Api\ApiResponse::class => [ + 'constructParams' => [ + $serverVars, + $getVars['callback'] ?? '', + ], ], - ], ]; })( dirname(__FILE__, 2),