From 45d18a48f26cd3188441a24739112ee816ba9939 Mon Sep 17 00:00:00 2001
From: core23 <mail@core23.de>
Date: Sat, 4 Jul 2020 18:04:27 +0200
Subject: [PATCH 1/2] Move configuration to PHP

---
 .../NucleosShariffExtension.php               |  8 +--
 src/Resources/config/action.php               | 26 ++++++++
 src/Resources/config/action.xml               |  9 ---
 src/Resources/config/block.php                | 25 ++++++++
 src/Resources/config/block.xml                |  9 ---
 src/Resources/config/services.php             | 63 +++++++++++++++++++
 src/Resources/config/services.xml             | 30 ---------
 7 files changed, 118 insertions(+), 52 deletions(-)
 create mode 100644 src/Resources/config/action.php
 delete mode 100644 src/Resources/config/action.xml
 create mode 100644 src/Resources/config/block.php
 delete mode 100644 src/Resources/config/block.xml
 create mode 100644 src/Resources/config/services.php
 delete mode 100644 src/Resources/config/services.xml

diff --git a/src/DependencyInjection/NucleosShariffExtension.php b/src/DependencyInjection/NucleosShariffExtension.php
index fa846983..e6662f06 100644
--- a/src/DependencyInjection/NucleosShariffExtension.php
+++ b/src/DependencyInjection/NucleosShariffExtension.php
@@ -27,10 +27,10 @@ public function load(array $configs, ContainerBuilder $container): void
         $configuration = new Configuration();
         $config        = $this->processConfiguration($configuration, $configs);
 
-        $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
-        $loader->load('action.xml');
-        $loader->load('block.xml');
-        $loader->load('services.xml');
+        $loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
+        $loader->load('action.php');
+        $loader->load('block.php');
+        $loader->load('services.php');
 
         $this->configureAliases($container, $config);
         $this->configureDomains($container, $config);
diff --git a/src/Resources/config/action.php b/src/Resources/config/action.php
new file mode 100644
index 00000000..e898418d
--- /dev/null
+++ b/src/Resources/config/action.php
@@ -0,0 +1,26 @@
+<?php
+
+/*
+ * (c) Christian Gripp <mail@core23.de>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\Loader\Configurator;
+
+use Nucleos\ShariffBundle\Action\BackendAction;
+use Nucleos\ShariffBundle\Backend\Backend;
+use Symfony\Component\DependencyInjection\Reference;
+
+return static function (ContainerConfigurator $container): void {
+    $container->services()
+
+        ->set(BackendAction::class)
+            ->public()
+            ->args([
+                new Reference(Backend::class),
+            ])
+
+    ;
+};
diff --git a/src/Resources/config/action.xml b/src/Resources/config/action.xml
deleted file mode 100644
index eca35d56..00000000
--- a/src/Resources/config/action.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-  <services>
-    <defaults public="true"/>
-    <service id="Nucleos\ShariffBundle\Action\BackendAction">
-      <argument type="service" id="Nucleos\ShariffBundle\Backend\Backend"/>
-    </service>
-  </services>
-</container>
diff --git a/src/Resources/config/block.php b/src/Resources/config/block.php
new file mode 100644
index 00000000..53855afa
--- /dev/null
+++ b/src/Resources/config/block.php
@@ -0,0 +1,25 @@
+<?php
+
+/*
+ * (c) Christian Gripp <mail@core23.de>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\Loader\Configurator;
+
+use Nucleos\ShariffBundle\Block\Service\ShariffShareBlockService;
+use Symfony\Component\DependencyInjection\Reference;
+
+return static function (ContainerConfigurator $container): void {
+    $container->services()
+
+        ->set('nucleos_shariff.block.share', ShariffShareBlockService::class)
+            ->tag('sonata.block')
+            ->args([
+                new Reference('twig'),
+            ])
+
+    ;
+};
diff --git a/src/Resources/config/block.xml b/src/Resources/config/block.xml
deleted file mode 100644
index b22f72bb..00000000
--- a/src/Resources/config/block.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-  <services>
-    <service id="nucleos_shariff.block.share" class="Nucleos\ShariffBundle\Block\Service\ShariffShareBlockService">
-      <tag name="sonata.block"/>
-      <argument type="service" id="twig"/>
-    </service>
-  </services>
-</container>
diff --git a/src/Resources/config/services.php b/src/Resources/config/services.php
new file mode 100644
index 00000000..726a8a53
--- /dev/null
+++ b/src/Resources/config/services.php
@@ -0,0 +1,63 @@
+<?php
+
+/*
+ * (c) Christian Gripp <mail@core23.de>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Symfony\Component\DependencyInjection\Loader\Configurator;
+
+use Nucleos\ShariffBundle\Backend\Backend;
+use Nucleos\ShariffBundle\Backend\PsrBackend;
+use Nucleos\ShariffBundle\Manager\ServiceManager;
+use Nucleos\ShariffBundle\Manager\StaticServiceManager;
+use Nucleos\ShariffBundle\Service\Facebook;
+use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\Parameter;
+use Symfony\Component\DependencyInjection\Reference;
+
+return static function (ContainerConfigurator $container): void {
+    $services = $container->services();
+
+    $services->load('Nucleos\\ShariffBundle\\Service\\', '../../Service')
+        ->exclude('../../Service/{Exception}')
+        ->public()
+        ->autowire()
+        ->autoconfigure()
+    ;
+
+    $services
+        ->set(Facebook::class)
+            ->tag('nucleos.shariff')
+            ->args([
+                new Parameter('nucleos_shariff.service.facebook.app_id'),
+                new Parameter('nucleos_shariff.service.facebook.secret'),
+                new Parameter('nucleos_shariff.service.facebook.version'),
+            ])
+
+        ->set(StaticServiceManager::class)
+            ->args([
+                [],
+                new Parameter('nucleos_shariff.services'),
+            ])
+
+        ->set(PsrBackend::class)
+            ->args([
+                new Reference(ServiceManager::class),
+                new Reference('nucleos_shariff.request_factory'),
+                new Reference('nucleos_shariff.http_client'),
+                new Reference('nucleos_shariff.cache'),
+                new Parameter('nucleos_shariff.domains'),
+            ])
+            ->call('setLogger', [
+                new Reference('logger', ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE),
+            ])
+
+        ->alias(ServiceManager::class, StaticServiceManager::class)
+
+        ->alias(Backend::class, PsrBackend::class)
+
+    ;
+};
diff --git a/src/Resources/config/services.xml b/src/Resources/config/services.xml
deleted file mode 100644
index 2445602f..00000000
--- a/src/Resources/config/services.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
-  <services>
-    <prototype namespace="Nucleos\ShariffBundle\Service\" resource="../../Service" exclude="../../Service/{Exception}" public="true" autowire="true" autoconfigure="true">
-      <tag name="nucleos.shariff"/>
-    </prototype>
-    <service id="Nucleos\ShariffBundle\Service\Facebook" public="true">
-      <tag name="nucleos.shariff"/>
-      <argument>%nucleos_shariff.service.facebook.app_id%</argument>
-      <argument>%nucleos_shariff.service.facebook.secret%</argument>
-      <argument>%nucleos_shariff.service.facebook.version%</argument>
-    </service>
-    <service id="Nucleos\ShariffBundle\Manager\ServiceManager" alias="Nucleos\ShariffBundle\Manager\StaticServiceManager"/>
-    <service id="Nucleos\ShariffBundle\Manager\StaticServiceManager">
-      <argument type="collection"/>
-      <argument>%nucleos_shariff.services%</argument>
-    </service>
-    <service id="Nucleos\ShariffBundle\Backend\Backend" alias="Nucleos\ShariffBundle\Backend\PsrBackend"/>
-    <service id="Nucleos\ShariffBundle\Backend\PsrBackend">
-      <argument type="service" id="Nucleos\ShariffBundle\Manager\ServiceManager"/>
-      <argument type="service" id="nucleos_shariff.request_factory"/>
-      <argument type="service" id="nucleos_shariff.http_client"/>
-      <argument type="service" id="nucleos_shariff.cache"/>
-      <argument>%nucleos_shariff.domains%</argument>
-      <call method="setLogger">
-        <argument type="service" id="logger" on-invalid="ignore_uninitialized"/>
-      </call>
-    </service>
-  </services>
-</container>

From 4fa17eb54447a9daf818124d76984c6224c0c9cf Mon Sep 17 00:00:00 2001
From: core23 <mail@core23.de>
Date: Sat, 4 Jul 2020 18:04:41 +0200
Subject: [PATCH 2/2] Extract infection config

---
 composer.json                 |  2 +-
 infection.json                | 21 ++++++++++++---------
 vendor-bin/test/composer.json | 12 ++++++------
 3 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/composer.json b/composer.json
index 7f98bd4e..aab4344d 100644
--- a/composer.json
+++ b/composer.json
@@ -77,7 +77,7 @@
         "cs": "PHP_CS_FIXER_IGNORE_ENV=1 && vendor/bin/php-cs-fixer fix --verbose",
         "cs-diff": "PHP_CS_FIXER_IGNORE_ENV=1 && vendor/bin/php-cs-fixer fix  --verbose --diff --diff-format=udiff --dry-run",
         "deps": "vendor/bin/composer-require-checker check --config-file composer-require.json composer.json",
-        "infection": "vendor/bin/infection --ignore-msi-with-no-mutations --min-covered-msi=25 --min-msi=18",
+        "infection": "vendor/bin/infection",
         "lint": [
             "find ./src \\( -name '*.xml' -or -name '*.xml.dist' -or -name '*.xlf' \\) -type f -exec xmllint --encode UTF-8 --output '{}' --format '{}' \\;",
             "find ./src \\( -name '*.yml' -or -name '*.yaml' \\) -not -path '*/vendor/*' | xargs yaml-lint"
diff --git a/infection.json b/infection.json
index 418c43a3..0aa06b27 100644
--- a/infection.json
+++ b/infection.json
@@ -1,11 +1,14 @@
 {
-  "timeout": 10,
-  "source": {
-    "directories": [
-      "src"
-    ]
-  },
-  "logs": {
-    "text": "build/infection/infection-log.txt"
-  }
+    "timeout": 10,
+    "source": {
+        "directories": [
+            "src"
+        ]
+    },
+    "logs": {
+        "text": "build/infection/infection-log.txt"
+    },
+    "ignoreMsiWithNoMutations": true,
+    "minMsi": 18,
+    "minCoveredMsi": 25
 }
diff --git a/vendor-bin/test/composer.json b/vendor-bin/test/composer.json
index 1b5e43ad..d5575934 100644
--- a/vendor-bin/test/composer.json
+++ b/vendor-bin/test/composer.json
@@ -1,8 +1,8 @@
 {
-  "require": {
-    "infection/infection": "^0.15",
-    "matthiasnoback/symfony-dependency-injection-test": "^4.0",
-    "phpunit/phpunit": "^9.0",
-    "symfony/phpunit-bridge": "^5.1"
-  }
+    "require": {
+        "infection/infection": "^0.16",
+        "matthiasnoback/symfony-dependency-injection-test": "^4.0",
+        "phpunit/phpunit": "^9.0",
+        "symfony/phpunit-bridge": "^5.1"
+    }
 }