summaryrefslogtreecommitdiffstats
path: root/php-bartlett-php-compatinfo-db-upstream.patch
blob: 82345d181043f8b175fbe444f1d42770809a2b27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
From d05aaa27ebd0d0d5fe61c34da10d4362c3223ea1 Mon Sep 17 00:00:00 2001
From: Laurent Laville <laurent.laville@gmail.com>
Date: Thu, 14 Jan 2021 07:22:07 +0000
Subject: [PATCH] fixes Symfony BC issue (#61)

---
 CHANGELOG-3.x.md                              |  4 ++
 composer.json                                 |  3 +-
 config/set/common.php                         |  2 +-
 config/set/default.php                        |  2 +-
 .../Framework/Symfony/Polyfill.php            | 40 +++++++++++++++++++
 .../Console/Command/AbstractCommand.php       |  3 ++
 .../Console/Command/DiagnoseCommand.php       |  3 +-
 .../Console/Command/InitCommand.php           |  3 +-
 .../Console/Command/ListCommand.php           |  3 +-
 .../Console/Command/ReleaseCommand.php        |  5 +--
 .../Console/Command/ShowCommand.php           |  6 +--
 11 files changed, 59 insertions(+), 15 deletions(-)
 create mode 100644 src/Infrastructure/Framework/Symfony/Polyfill.php

diff --git a/CHANGELOG-3.x.md b/CHANGELOG-3.x.md
index 2dc124b..0229ff1 100644
--- a/CHANGELOG-3.x.md
+++ b/CHANGELOG-3.x.md
@@ -6,6 +6,10 @@ using the [Keep a CHANGELOG](http://keepachangelog.com) principles.
 
 ## [Unreleased]
 
+### Fixed
+
+- [#61](https://github.com/llaville/php-compatinfo-db/issues/61) Keep Symfony 4.4 Backward Compatibility
+
 ## [3.1.0] - 2021-01-09
 
 ### Added
diff --git a/composer.json b/composer.json
index 5171be1..3448740 100644
--- a/composer.json
+++ b/composer.json
@@ -48,7 +48,8 @@
     "autoload": {
         "psr-4": {
             "Bartlett\\CompatInfoDb\\": "src/"
-        }
+        },
+        "files": ["src/Infrastructure/Framework/Symfony/Polyfill.php"]
     },
     "autoload-dev": {
         "psr-4": {
diff --git a/config/set/common.php b/config/set/common.php
index ef25457..f480a16 100644
--- a/config/set/common.php
+++ b/config/set/common.php
@@ -7,6 +7,7 @@
 use Bartlett\CompatInfoDb\Presentation\Console\Command\FactoryCommandLoader;
 use Bartlett\CompatInfoDb\Presentation\Console\Input\Input;
 use Bartlett\CompatInfoDb\Presentation\Console\Output\Output;
+use function Bartlett\CompatInfoDb\Infrastructure\Framework\Symfony\service;
 
 use Symfony\Component\Console\CommandLoader\CommandLoaderInterface;
 use Symfony\Component\Console\Input\InputInterface;
@@ -15,7 +16,6 @@
 use Symfony\Component\EventDispatcher\EventDispatcherInterface;
 use Symfony\Component\EventDispatcher\EventSubscriberInterface;
 use Symfony\Component\Stopwatch\Stopwatch;
-use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
 use function Symfony\Component\DependencyInjection\Loader\Configurator\tagged_iterator;
 
 /**
diff --git a/config/set/default.php b/config/set/default.php
index 413eb33..25ff7e8 100644
--- a/config/set/default.php
+++ b/config/set/default.php
@@ -16,6 +16,7 @@
 use Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Repository\PlatformRepository as InfrastructurePlatformRepository;
 use Bartlett\CompatInfoDb\Application\Service\JsonFileHandler;
 use Bartlett\CompatInfoDb\Presentation\Console\Command\CommandInterface;
+use function Bartlett\CompatInfoDb\Infrastructure\Framework\Symfony\service;
 
 use Composer\Semver\VersionParser;
 
@@ -25,7 +26,6 @@
 
 use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
 use Symfony\Component\Messenger\Command\DebugCommand;
-use function Symfony\Component\DependencyInjection\Loader\Configurator\service;
 
 /**
  * Build the Container with default parameters and services
diff --git a/src/Infrastructure/Framework/Symfony/Polyfill.php b/src/Infrastructure/Framework/Symfony/Polyfill.php
new file mode 100644
index 0000000..7aff5e5
--- /dev/null
+++ b/src/Infrastructure/Framework/Symfony/Polyfill.php
@@ -0,0 +1,40 @@
+<?php declare(strict_types=1);
+
+/**
+ * Keep BC between Symfony 4.4 and Symfony 5.x
+ *
+ * PHP version 7
+ *
+ * @category   PHP
+ * @package    PHP_CompatInfo_Db
+ * @author     Laurent Laville <pear@laurent-laville.org>
+ * @license    https://opensource.org/licenses/BSD-3-Clause The 3-Clause BSD License
+ * @link       http://bartlett.laurent-laville.org/php-compatinfo/
+ */
+
+namespace Bartlett\CompatInfoDb\Infrastructure\Framework\Symfony;
+
+use Symfony\Component\DependencyInjection\Loader\Configurator\ReferenceConfigurator;
+
+/**
+ * @since 3.1.1
+ * @see https://github.com/llaville/php-compatinfo-db/issues/61
+ */
+final class Polyfill
+{
+    /**
+     * Creates a reference to a service.
+     *
+     * @param string $serviceId
+     * @return ReferenceConfigurator
+     */
+    public static function service(string $serviceId): ReferenceConfigurator
+    {
+        return new ReferenceConfigurator($serviceId);
+    }
+}
+
+function service(string $serviceId): ReferenceConfigurator
+{
+    return Polyfill::service($serviceId);
+}
diff --git a/src/Presentation/Console/Command/AbstractCommand.php b/src/Presentation/Console/Command/AbstractCommand.php
index 998905f..5a9b2a3 100644
--- a/src/Presentation/Console/Command/AbstractCommand.php
+++ b/src/Presentation/Console/Command/AbstractCommand.php
@@ -24,6 +24,9 @@
  */
 abstract class AbstractCommand extends Command
 {
+    public const SUCCESS = 0;
+    public const FAILURE = 1;
+
     /** @var CommandBusInterface */
     protected $commandBus;
 
diff --git a/src/Presentation/Console/Command/DiagnoseCommand.php b/src/Presentation/Console/Command/DiagnoseCommand.php
index 01527fd..6f2881c 100644
--- a/src/Presentation/Console/Command/DiagnoseCommand.php
+++ b/src/Presentation/Console/Command/DiagnoseCommand.php
@@ -22,7 +22,6 @@
 
 use Doctrine\ORM\EntityManagerInterface;
 
-use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 
@@ -65,6 +64,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
         $checker->setAppName('PHP CompatInfoDB');
         $checker->printDiagnostic($projectRequirements);
 
-        return Command::SUCCESS;
+        return self::SUCCESS;
     }
 }
diff --git a/src/Presentation/Console/Command/InitCommand.php b/src/Presentation/Console/Command/InitCommand.php
index b1e5722..80c54fa 100644
--- a/src/Presentation/Console/Command/InitCommand.php
+++ b/src/Presentation/Console/Command/InitCommand.php
@@ -18,7 +18,6 @@
 use Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface;
 use Bartlett\CompatInfoDb\Presentation\Console\Style;
 
-use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
@@ -59,7 +58,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
 
         $exitCode = $this->queryBus->query($initQuery);
 
-        if (Command::SUCCESS === $exitCode) {
+        if (self::SUCCESS === $exitCode) {
             $io->success('Database built successfully!');
         } else {
             $io->warning('Database already exists.');
diff --git a/src/Presentation/Console/Command/ListCommand.php b/src/Presentation/Console/Command/ListCommand.php
index 350ccb8..3f47f6d 100644
--- a/src/Presentation/Console/Command/ListCommand.php
+++ b/src/Presentation/Console/Command/ListCommand.php
@@ -20,7 +20,6 @@
 use Bartlett\CompatInfoDb\Presentation\Console\ApplicationInterface;
 use Bartlett\CompatInfoDb\Presentation\Console\Style;
 
-use Symfony\Component\Console\Command\Command;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
 use Symfony\Component\Console\Helper\TableSeparator;
@@ -105,6 +104,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
             )
         );
 
-        return Command::SUCCESS;
+        return self::SUCCESS;
     }
 }
diff --git a/src/Presentation/Console/Command/ReleaseCommand.php b/src/Presentation/Console/Command/ReleaseCommand.php
index 2315f5d..8f2049d 100644
--- a/src/Presentation/Console/Command/ReleaseCommand.php
+++ b/src/Presentation/Console/Command/ReleaseCommand.php
@@ -15,9 +15,8 @@
 namespace Bartlett\CompatInfoDb\Presentation\Console\Command;
 
 use Bartlett\CompatInfoDb\Application\Command\Release\ReleaseCommand as AppReleaseCommand;
-
 use Bartlett\CompatInfoDb\Presentation\Console\Style;
-use Symfony\Component\Console\Command\Command;
+
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputInterface;
 use Symfony\Component\Console\Output\OutputInterface;
@@ -69,6 +68,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
         $io->success('New release was added in JSON files');
         $io->note('Do not forget to update constants of ExtensionVersionProviderInterface');
 
-        return Command::SUCCESS;
+        return self::SUCCESS;
     }
 }
diff --git a/src/Presentation/Console/Command/ShowCommand.php b/src/Presentation/Console/Command/ShowCommand.php
index 7b3254f..c16bfce 100644
--- a/src/Presentation/Console/Command/ShowCommand.php
+++ b/src/Presentation/Console/Command/ShowCommand.php
@@ -81,7 +81,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
 
         if (null === $extension) {
             $io->error(sprintf('Extension "%s" is not available', $showQuery->getExtension()));
-            return Command::FAILURE;
+            return self::FAILURE;
         }
 
         $summary = true;
@@ -120,7 +120,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
         }
 
         if (!$summary) {
-            return Command::SUCCESS;
+            return self::SUCCESS;
         }
 
         $io->title('Reference Summary');
@@ -157,7 +157,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
             '  Methods                                   %10d'
         );
 
-        return Command::SUCCESS;
+        return self::SUCCESS;
     }
 
     private function formatSection(array $data, string $section, StyleInterface $io): void