File: 0008-Upgrade-php-di-to-v7.patch

package info (click to toggle)
matomo 5.5.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 73,220 kB
  • sloc: php: 230,901; javascript: 102,286; python: 196; xml: 189; sh: 156; makefile: 13; sql: 10
file content (105 lines) | stat: -rw-r--r-- 3,889 bytes parent folder | download
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
From: William Desportes <williamdes@wdes.fr>
Date: Sun, 15 Dec 2024 12:01:42 +0100
Subject: Upgrade php-di to v7

By reading: https://php-di.org/doc/migration/7.0.html
The code uses `useAnnotations(false);`, that means no annotation needs to be changed.
And there is no use of `buildDevContainer`

Origin: vendor
Forwarded: https://github.com/matomo-org/matomo/pull/22863
---
 composer.json                                |  2 +-
 core/Container/Container.php                 | 10 +++++-----
 core/Container/ContainerFactory.php          |  2 --
 core/Container/IniConfigDefinitionSource.php |  2 +-
 4 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/composer.json b/composer.json
index 645b551..24aa3db 100644
--- a/composer.json
+++ b/composer.json
@@ -57,7 +57,7 @@
         "monolog/monolog": "~1.11",
         "mustangostang/spyc": "^0.6.0",
         "pear/pear_exception": "*",
-        "php-di/php-di": "^6.0.0",
+        "php-di/php-di": "^7.0.0",
         "phpmailer/phpmailer": "^6.1",
         "psr/log": "~1.0",
         "symfony/console": ">=6.4 <8",
diff --git a/core/Container/Container.php b/core/Container/Container.php
index a37d106..455e725 100644
--- a/core/Container/Container.php
+++ b/core/Container/Container.php
@@ -11,7 +11,7 @@ namespace Piwik\Container;
 
 use DI\Container as DIContainer;
 use DI\Definition\Source\MutableDefinitionSource;
-use DI\Proxy\ProxyFactory;
+use DI\Proxy\ProxyFactoryInterface;
 use Piwik\Exception\DI\DependencyException;
 use Piwik\Exception\DI\NotFoundException;
 use Psr\Container\ContainerInterface;
@@ -24,7 +24,7 @@ class Container extends DIContainer implements ContainerInterface
 {
     public function __construct(
         ?MutableDefinitionSource $definitionSource = null,
-        ?ProxyFactory $proxyFactory = null,
+        ?ProxyFactoryInterface $proxyFactory = null,
         ?ContainerInterface $wrapperContainer = null
     ) {
         parent::__construct($definitionSource, $proxyFactory, $wrapperContainer);
@@ -32,7 +32,7 @@ class Container extends DIContainer implements ContainerInterface
         $this->resolvedEntries[self::class] = $this;
     }
 
-    public function get($name)
+    public function get(string $name): mixed
     {
         try {
             return parent::get($name);
@@ -41,7 +41,7 @@ class Container extends DIContainer implements ContainerInterface
         }
     }
 
-    public function make($name, array $parameters = [])
+    public function make(string $name, array $parameters = []): mixed
     {
         try {
             return parent::make($name, $parameters);
@@ -52,7 +52,7 @@ class Container extends DIContainer implements ContainerInterface
         }
     }
 
-    public function injectOn($instance)
+    public function injectOn(object $instance): object
     {
         try {
             return parent::injectOn($instance);
diff --git a/core/Container/ContainerFactory.php b/core/Container/ContainerFactory.php
index 63eab87..2509dab 100644
--- a/core/Container/ContainerFactory.php
+++ b/core/Container/ContainerFactory.php
@@ -64,8 +64,6 @@ class ContainerFactory
     {
         $builder = new ContainerBuilder(Container::class);
 
-        $builder->useAnnotations(false);
-
         // INI config
         $builder->addDefinitions(new IniConfigDefinitionSource($this->settings));
 
diff --git a/core/Container/IniConfigDefinitionSource.php b/core/Container/IniConfigDefinitionSource.php
index 69a65ae..79b9f2b 100644
--- a/core/Container/IniConfigDefinitionSource.php
+++ b/core/Container/IniConfigDefinitionSource.php
@@ -46,7 +46,7 @@ class IniConfigDefinitionSource implements DefinitionSource
     /**
      * {@inheritdoc}
      */
-    public function getDefinition($name)
+    public function getDefinition(?string $name): ?\DI\Definition\Definition
     {
         if (strpos($name, $this->prefix) !== 0) {
             return null;