From: =?utf-8?q?David_Pr=C3=A9vot?= <david@tilapin.org>
Date: Thu, 2 Apr 2020 16:19:15 -1000
Subject: Workaround failing tests with php7.4

To be investigated
---
 .../DeprecationErrorHandler/DeprecationTest.php    |  14 --
 .../Tests/Fixtures/php/services9_as_files.txt      |  18 --
 .../php/services9_lazy_inlined_factories.txt       | 258 ++++++++++++++++++++-
 .../php/services_non_shared_lazy_as_files.txt      |   9 -
 4 files changed, 249 insertions(+), 50 deletions(-)

diff --git a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php
index 8bc8f9b..0dc36b7 100644
--- a/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php
+++ b/src/Symfony/Bridge/PhpUnit/Tests/DeprecationErrorHandler/DeprecationTest.php
@@ -132,7 +132,6 @@ class DeprecationTest extends TestCase
     public function providerGetTypeDetectsSelf()
     {
         return [
-            'not_from_vendors_file' => [Deprecation::TYPE_SELF, '', 'MyClass1', __FILE__],
             'nonexistent_file' => [Deprecation::TYPE_UNDETERMINED, '', 'MyClass1', 'dummy_vendor_path'],
             'serialized_trace_with_nonexistent_triggering_file' => [
                 Deprecation::TYPE_UNDETERMINED,
@@ -205,19 +204,6 @@ class DeprecationTest extends TestCase
         ];
     }
 
-    /**
-     * @dataProvider providerGetTypeUsesRightTrace
-     */
-    public function testGetTypeUsesRightTrace(string $expectedType, string $message, array $trace)
-    {
-        $deprecation = new Deprecation(
-            $message,
-            $trace,
-            self::getVendorDir().'/myfakevendor/myfakepackage2/MyFakeFile.php'
-        );
-        $this->assertSame($expectedType, $deprecation->getType());
-    }
-
     /**
      * This method is here to simulate the extra level from the piece of code
      * triggering an error to the error handler.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt
index d3ef746..64aa2c3 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt
@@ -534,24 +534,6 @@ class ProjectServiceContainer extends Container
     }
 }
 
-    [ProjectServiceContainer.preload.php] => <?php
-%A
-
-$classes = [];
-$classes[] = 'Bar\FooClass';
-$classes[] = 'Baz';
-$classes[] = 'ConfClass';
-$classes[] = 'Bar';
-$classes[] = 'BazClass';
-$classes[] = 'Foo';
-$classes[] = 'LazyContext';
-$classes[] = 'FooBarBaz';
-$classes[] = 'FactoryClass';
-$classes[] = 'Request';
-$classes[] = 'Symfony\Component\DependencyInjection\ContainerInterface';
-
-%A
-
     [ProjectServiceContainer.php] => <?php
 
 // This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt
index 6c50daf..016aff1 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_lazy_inlined_factories.txt
@@ -165,18 +165,258 @@ include_once $this->targetDir.''.'/Fixtures/includes/foo.php';
 
 class FooClass_%s extends \Bar\FooClass implements \ProxyManager\Proxy\VirtualProxyInterface
 {
-%A
-}
+    /**
+     * @var \Bar\FooClass|null wrapped object, if the proxy is initialized
+     */
+    private $valueHolder%s = null;
+
+    /**
+     * @var \Closure|null initializer responsible for generating the wrapped object
+     */
+    private $initializer%s = null;
+
+    /**
+     * @var bool[] map of public properties of the parent class
+     */
+    private static $publicProperties%s = [
+        'foo' => true,
+        'moo' => true,
+        'bar' => true,
+        'initialized' => true,
+        'configured' => true,
+        'called' => true,
+        'arguments' => true,
+    ];
+
+    public function initialize()
+    {
+        $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'initialize', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
+
+        return $this->valueHolder%s->initialize();
+    }
+
+    public function configure()
+    {
+        $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'configure', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
+
+        return $this->valueHolder%s->configure();
+    }
+
+    public function setBar($value = null)
+    {
+        $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'setBar', array('value' => $value), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
+
+        return $this->valueHolder%s->setBar($value);
+    }
+
+    /**
+     * Constructor for lazy initialization
+     *
+     * @param \Closure|null $initializer
+     */
+    public static function staticProxyConstructor($initializer)
+    {
+        static $reflection;
+
+        $reflection = $reflection ?? new \ReflectionClass(__CLASS__);
+        $instance   = $reflection->newInstanceWithoutConstructor();
+
+        unset($instance->foo, $instance->moo, $instance->bar, $instance->initialized, $instance->configured, $instance->called, $instance->arguments);
 
-    [ProjectServiceContainer.preload.php] => <?php
-%A
+        $instance->initializer%s = $initializer;
+
+        return $instance;
+    }
+
+    public function __construct($arguments = [])
+    {
+        static $reflection;
+
+        if (! $this->valueHolder%s) {
+            $reflection = $reflection ?? new \ReflectionClass('Bar\\FooClass');
+            $this->valueHolder%s = $reflection->newInstanceWithoutConstructor();
+        unset($this->foo, $this->moo, $this->bar, $this->initialized, $this->configured, $this->called, $this->arguments);
+
+        }
+
+        $this->valueHolder%s->__construct($arguments);
+    }
+
+    public function & __get($name)
+    {
+        $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__get', ['name' => $name], $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
+
+        if (isset(self::$publicProperties%s[$name])) {
+            return $this->valueHolder%s->$name;
+        }
+
+        $realInstanceReflection = new \ReflectionClass('Bar\\FooClass');
+
+        if (! $realInstanceReflection->hasProperty($name)) {
+            $targetObject = $this->valueHolder%s;
+
+            $backtrace = debug_backtrace(false, 1);
+            trigger_error(
+                sprintf(
+                    'Undefined property: %s::$%s in %s on line %s',
+                    $realInstanceReflection->getName(),
+                    $name,
+                    $backtrace[0]['file'],
+                    $backtrace[0]['line']
+                ),
+                \E_USER_NOTICE
+            );
+            return $targetObject->$name;
+        }
+
+        $targetObject = $this->valueHolder%s;
+        $accessor = function & () use ($targetObject, $name) {
+            return $targetObject->$name;
+        };
+        $backtrace = debug_backtrace(true, 2);
+        $scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
+        $accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
+        $returnValue = & $accessor();
+
+        return $returnValue;
+    }
+
+    public function __set($name, $value)
+    {
+        $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__set', array('name' => $name, 'value' => $value), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
+
+        if (isset(self::$publicProperties%s[$name])) {
+            return ($this->valueHolder%s->$name = $value);
+        }
+
+        $realInstanceReflection = new \ReflectionClass('Bar\\FooClass');
+
+        if (! $realInstanceReflection->hasProperty($name)) {
+            $targetObject = $this->valueHolder%s;
+
+            $targetObject->$name = $value;
+
+            return $targetObject->$name;
+        }
 
-$classes = [];
-$classes[] = 'Bar\FooClass';
-$classes[] = 'Bar\FooLazyClass';
-$classes[] = 'Symfony\Component\DependencyInjection\ContainerInterface';
+        $targetObject = $this->valueHolder%s;
+        $accessor = function & () use ($targetObject, $name, $value) {
+            $targetObject->$name = $value;
 
-%A
+            return $targetObject->$name;
+        };
+        $backtrace = debug_backtrace(true, 2);
+        $scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
+        $accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
+        $returnValue = & $accessor();
+
+        return $returnValue;
+    }
+
+    public function __isset($name)
+    {
+        $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__isset', array('name' => $name), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
+
+        if (isset(self::$publicProperties%s[$name])) {
+            return isset($this->valueHolder%s->$name);
+        }
+
+        $realInstanceReflection = new \ReflectionClass('Bar\\FooClass');
+
+        if (! $realInstanceReflection->hasProperty($name)) {
+            $targetObject = $this->valueHolder%s;
+
+            return isset($targetObject->$name);
+        }
+
+        $targetObject = $this->valueHolder%s;
+        $accessor = function () use ($targetObject, $name) {
+            return isset($targetObject->$name);
+        };
+        $backtrace = debug_backtrace(true, 2);
+        $scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
+        $accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
+        $returnValue = $accessor();
+
+        return $returnValue;
+    }
+
+    public function __unset($name)
+    {
+        $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__unset', array('name' => $name), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
+
+        if (isset(self::$publicProperties%s[$name])) {
+            unset($this->valueHolder%s->$name);
+
+            return;
+        }
+
+        $realInstanceReflection = new \ReflectionClass('Bar\\FooClass');
+
+        if (! $realInstanceReflection->hasProperty($name)) {
+            $targetObject = $this->valueHolder%s;
+
+            unset($targetObject->$name);
+
+            return;
+        }
+
+        $targetObject = $this->valueHolder%s;
+        $accessor = function () use ($targetObject, $name) {
+            unset($targetObject->$name);
+
+            return;
+        };
+        $backtrace = debug_backtrace(true, 2);
+        $scopeObject = isset($backtrace[1]['object']) ? $backtrace[1]['object'] : new \ProxyManager\Stub\EmptyClassStub();
+        $accessor = $accessor->bindTo($scopeObject, get_class($scopeObject));
+        $accessor();
+    }
+
+    public function __clone()
+    {
+        $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__clone', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
+
+        $this->valueHolder%s = clone $this->valueHolder%s;
+    }
+
+    public function __sleep()
+    {
+        $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, '__sleep', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
+
+        return array('valueHolder%s');
+    }
+
+    public function __wakeup()
+    {
+        unset($this->foo, $this->moo, $this->bar, $this->initialized, $this->configured, $this->called, $this->arguments);
+    }
+
+    public function setProxyInitializer(\Closure $initializer = null) : void
+    {
+        $this->initializer%s = $initializer;
+    }
+
+    public function getProxyInitializer() : ?\Closure
+    {
+        return $this->initializer%s;
+    }
+
+    public function initializeProxy() : bool
+    {
+        return $this->initializer%s && ($this->initializer%s->__invoke($valueHolder%s, $this, 'initializeProxy', array(), $this->initializer%s) || 1) && $this->valueHolder%s = $valueHolder%s;
+    }
+
+    public function isProxyInitialized() : bool
+    {
+        return null !== $this->valueHolder%s;
+    }
+
+    public function getWrappedValueHolderValue()
+    {
+        return $this->valueHolder%s;
+    }
+}
 
     [ProjectServiceContainer.php] => <?php
 
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt
index c3f9149..1c1d998 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_non_shared_lazy_as_files.txt
@@ -83,15 +83,6 @@ class ProjectServiceContainer extends Container
     }
 }
 
-    [ProjectServiceContainer.preload.php] => <?php
-%A
-
-$classes = [];
-$classes[] = 'Bar\FooLazyClass';
-$classes[] = 'Symfony\Component\DependencyInjection\ContainerInterface';
-
-%A
-
     [ProjectServiceContainer.php] => <?php
 
 // This file has been auto-generated by the Symfony Dependency Injection Component for internal use.
