Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ProxyManagerBridge should possibly use Lazy Loading Ghost Object Proxies instead of Lazy Loading Value Holder Proxies #35345

Closed
@ostrolucky

Description

@ostrolucky

I have created new issue to make it less doctrine specific.

Here is demonstration of different lazy proxies (modified proxy-manager examples)

use ProxyManager\Factory\LazyLoadingGhostFactory;
use ProxyManager\Factory\LazyLoadingValueHolderFactory;

class Foo
{
    public function compare(self $foo)
    {
        var_dump($foo === $this);
    }
}


$proxy = (new LazyLoadingValueHolderFactory())->createProxy(Foo::class, function (&$wrappedObject) {
    $wrappedObject = new Foo();
    return true;
});

$proxy->compare($proxy); // bool(false)

$proxy = (new LazyLoadingGhostFactory())->createProxy(Foo::class, fn() => true);
$proxy->compare($proxy); // bool(true)

First approach is used by Symfony. As you can see, it breaks identity and is more complicated to use. I suggest to use second method, which doesn't break identities. Would solve #35216 and issues related to it.

cc @stof

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions