]> git.mxchange.org Git - friendica.git/commitdiff
Using method-chaining for DICE
authorPhilipp Holzer <admin+github@philipp.info>
Mon, 5 Aug 2019 07:02:55 +0000 (09:02 +0200)
committerPhilipp Holzer <admin+github@philipp.info>
Mon, 5 Aug 2019 07:03:12 +0000 (09:03 +0200)
bin/auth_ejabberd.php
bin/console.php
bin/daemon.php
bin/worker.php
index.php
tests/functional/DependencyCheckTest.php
tests/include/ApiTest.php
tests/src/Database/DBATest.php
tests/src/Database/DBStructureTest.php

index a097febbce3f43f9be2099ff7fb71e61c516f93c..206e484470058bff0aa98c3625f2f47b4f29e0e4 100755 (executable)
@@ -32,6 +32,7 @@
  *
  */
 
+use Dice\Dice;
 use Friendica\App\Mode;
 use Friendica\BaseObject;
 use Friendica\Util\ExAuth;
@@ -52,8 +53,7 @@ chdir($directory);
 
 require dirname(__DIR__) . '/vendor/autoload.php';
 
-$dice = new \Dice\Dice();
-$dice = $dice->addRules(include __DIR__ . '/../static/dependencies.config.php');
+$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
 BaseObject::setDependencyInjection($dice);
 
 $appMode = $dice->create(Mode::class);
index 3a64d1d2a05060ae51b808225290be9b86582bfd..4c396854dc09c06564f5c4e86b01c645f49dfc5c 100755 (executable)
@@ -1,9 +1,10 @@
 #!/usr/bin/env php
 <?php
 
+use Dice\Dice;
+
 require dirname(__DIR__) . '/vendor/autoload.php';
 
-$dice = new \Dice\Dice();
-$dice = $dice->addRules(include __DIR__ . '/../static/dependencies.config.php');
+$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
 
 (new Friendica\Core\Console($dice, $argv))->execute();
index ac6385cbb973fb2d7680cdc6cde4e45c326e5fbd..8ea60fa9ac79b86f247f30325e222de011c8df5c 100755 (executable)
@@ -7,6 +7,7 @@
  * This script was taken from http://php.net/manual/en/function.pcntl-fork.php
  */
 
+use Dice\Dice;
 use Friendica\Core\Config;
 use Friendica\Core\Logger;
 use Friendica\Core\Worker;
@@ -31,8 +32,7 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
 
 require dirname(__DIR__) . '/vendor/autoload.php';
 
-$dice = new \Dice\Dice();
-$dice = $dice->addRules(include __DIR__ . '/../static/dependencies.config.php');
+$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
 
 \Friendica\BaseObject::setDependencyInjection($dice);
 $a = \Friendica\BaseObject::getApp();
index e630ee2347637c7a5da97eefe4e05fbd23de70a9..f6b2d90a59313ab088f2653e8a61417a62e67465 100755 (executable)
@@ -5,7 +5,9 @@
  * @brief Starts the background processing
  */
 
+use Dice\Dice;
 use Friendica\App;
+use Friendica\BaseObject;
 use Friendica\Core\Config;
 use Friendica\Core\Update;
 use Friendica\Core\Worker;
@@ -29,11 +31,10 @@ if (!file_exists("boot.php") && (sizeof($_SERVER["argv"]) != 0)) {
 
 require dirname(__DIR__) . '/vendor/autoload.php';
 
-$dice = new \Dice\Dice();
-$dice = $dice->addRules(include __DIR__ . '/../static/dependencies.config.php');
+$dice = (new Dice())->addRules(include __DIR__ . '/../static/dependencies.config.php');
 
-\Friendica\BaseObject::setDependencyInjection($dice);
-$a = \Friendica\BaseObject::getApp();
+BaseObject::setDependencyInjection($dice);
+$a = BaseObject::getApp();
 
 // Check the database structure and possibly fixes it
 Update::check($a->getBasePath(), true, $a->getMode());
index 3e560970892ffdcc0152b865157777fd1a6add9b..50e553bcd892f71e967662a5cb1990066a301ce9 100644 (file)
--- a/index.php
+++ b/index.php
@@ -4,14 +4,15 @@
  * Friendica
  */
 
+use Dice\Dice;
+
 if (!file_exists(__DIR__ . '/vendor/autoload.php')) {
        die('Vendor path not found. Please execute "bin/composer.phar --no-dev install" on the command line in the web root.');
 }
 
 require __DIR__ . '/vendor/autoload.php';
 
-$dice = new \Dice\Dice();
-$dice = $dice->addRules(include __DIR__ . '/static/dependencies.config.php');
+$dice = (new Dice())->addRules(include __DIR__ . '/static/dependencies.config.php');
 
 \Friendica\BaseObject::setDependencyInjection($dice);
 
index bc8d256a78f821c3f4c98ba182c0102ba50d33f4..2a3eed5973048bdae28c5fa967c82f1811076964 100644 (file)
@@ -32,8 +32,8 @@ class dependencyCheck extends TestCase
 
                $this->setUpVfsDir();
 
-               $this->dice = new Dice();
-               $this->dice = $this->dice->addRules(include __DIR__ . '/../../static/dependencies.config.php');
+               $this->dice = (new Dice())
+                       ->addRules(include __DIR__ . '/../../static/dependencies.config.php');
        }
 
        /**
@@ -87,8 +87,7 @@ class dependencyCheck extends TestCase
                ]);
 
                // create new DI-library because of shared instance rule (so the Profiler wouldn't get created twice)
-               $this->dice = new Dice(include __DIR__ . '/../../static/dependencies.config.php');
-               $profiler = $this->dice->create(Profiler::class, [$configCache]);
+               $this->dice = (new Dice())->create(Profiler::class, [$configCache]);
 
                $this->assertInstanceOf(Profiler::class, $profiler);
                $this->assertTrue($profiler->isRendertime());
index 098337aab9cea8e80638a9cc811d158437ecc059..3410f3049df83a1660b9c7cd0c76ca1c773c653d 100644 (file)
@@ -57,9 +57,9 @@ class ApiTest extends DatabaseTest
        {
                parent::setUp();
 
-               $this->dice = new Dice();
-               $this->dice = $this->dice->addRules(include __DIR__ . '/../../static/dependencies.config.php');
-               $this->dice = $this->dice->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
+               $this->dice = (new Dice())
+                       ->addRules(include __DIR__ . '/../../static/dependencies.config.php')
+                       ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
                BaseObject::setDependencyInjection($this->dice);
 
                /** @var Database $dba */
index 6d52581a98c2d3af94dd76f5309a8e7ee5a93569..9b2a2f122b608467f676145094445ac282ea8697 100644 (file)
@@ -15,9 +15,9 @@ class DBATest extends DatabaseTest
        {
                parent::setUp();
 
-               $dice = new Dice();
-               $dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
-               $dice = $dice->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
+               $dice = (new Dice())
+                       ->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
+                       ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
                BaseObject::setDependencyInjection($dice);
 
                // Default config
index e2938e3048ee12f2b4b0d2dff6e88a0f1577d717..38c621d4c8794948b5a4a2c2a25abf573db79cbf 100644 (file)
@@ -15,9 +15,9 @@ class DBStructureTest extends DatabaseTest
        {
                parent::setUp();
 
-               $dice = new Dice();
-               $dice = $dice->addRules(include __DIR__ . '/../../../static/dependencies.config.php');
-               $dice = $dice->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
+               $dice = (new Dice())
+                       ->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
+                       ->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true]);
                BaseObject::setDependencyInjection($dice);
        }