Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Prototype] Lazyload class instantiation in service container #6377

Draft
wants to merge 5 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"brain/monkey": "^2.0",
"coenjacobs/mozart": "^0.7",
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
"friendsofphp/proxy-manager-lts": "^1.0",
"league/container": "^3.3",
"mikey179/vfsstream": "1.6.11",
"mnsami/composer-custom-directory-installer": "^2.0",
Expand All @@ -62,6 +63,7 @@
"woocommerce/action-scheduler": "^3.4",
"wp-coding-standards/wpcs": "^3",
"wp-media/background-processing": "^1.3",
"wp-media/monolog": "^0.0",
"wp-media/phpunit": "^3",
"wp-media/rocket-lazyload-common": "^3.0.11",
"wp-media/wp-imagify-partner": "^1.0",
Expand All @@ -72,8 +74,7 @@
"wpackagist-plugin/simple-custom-css": "^4.0.3",
"wpackagist-plugin/spinupwp": "^1.1",
"wpackagist-plugin/woocommerce": "^7",
"wpackagist-plugin/wp-smushit": "^3",
"wp-media/monolog": "^0.0"
"wpackagist-plugin/wp-smushit": "^3"
},
"autoload": {
"classmap": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,253 @@
<?php

namespace ProxyManagerGeneratedProxy\__PM__\WP_Rocket\Addon\Sucuri\Subscriber;

class Generated9f012666a043b55e7acd66014aa7e8e3 extends \WP_Rocket\Addon\Sucuri\Subscriber implements \ProxyManager\Proxy\VirtualProxyInterface
{
/**
* @var \WP_Rocket\Addon\Sucuri\Subscriber|null wrapped object, if the proxy is initialized
*/
private $valueHolder5c912 = null;

/**
* @var \Closure|null initializer responsible for generating the wrapped object
*/
private $initializerb4055 = null;

/**
* @var bool[] map of public properties of the parent class
*/
private static $publicProperties3f2b9 = [

];

private static $signature9f012666a043b55e7acd66014aa7e8e3 = 'YTo0OntzOjk6ImNsYXNzTmFtZSI7czozMzoiV1BfUm9ja2V0XEFkZG9uXFN1Y3VyaVxTdWJzY3JpYmVyIjtzOjc6ImZhY3RvcnkiO3M6NTA6IlByb3h5TWFuYWdlclxGYWN0b3J5XExhenlMb2FkaW5nVmFsdWVIb2xkZXJGYWN0b3J5IjtzOjE5OiJwcm94eU1hbmFnZXJWZXJzaW9uIjtzOjQ4OiJ2MS4wLjE2QGVjYWRiZGM5MDUyZTRhZDA4YzYwYzhhMDIyNjg3MTJlNTA0MjdmN2MiO3M6MTI6InByb3h5T3B0aW9ucyI7YTowOnt9fQ==';

public function maybe_clean_firewall_cache()
{
$this->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, 'maybe_clean_firewall_cache', array(), $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;

return $this->valueHolder5c912->maybe_clean_firewall_cache();
}

public function do_admin_post_rocket_purge_sucuri()
{
$this->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, 'do_admin_post_rocket_purge_sucuri', array(), $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;

return $this->valueHolder5c912->do_admin_post_rocket_purge_sucuri();
}

public function maybe_print_notice()
{
$this->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, 'maybe_print_notice', array(), $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;

return $this->valueHolder5c912->maybe_print_notice();
}

public function add_cdn_helper_message(array $addons) : array
{
$this->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, 'add_cdn_helper_message', array('addons' => $addons), $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;

return $this->valueHolder5c912->add_cdn_helper_message($addons);
}

/**
* Constructor for lazy initialization
*
* @param \Closure|null $initializer
*/
public static function staticProxyConstructor($initializer)
{
static $reflection;

$reflection = $reflection ?? new \ReflectionClass(__CLASS__);
$instance = $reflection->newInstanceWithoutConstructor();

\Closure::bind(function (\WP_Rocket\Addon\Sucuri\Subscriber $instance) {
unset($instance->options);
}, $instance, 'WP_Rocket\\Addon\\Sucuri\\Subscriber')->__invoke($instance);

$instance->initializerb4055 = $initializer;

return $instance;
}

public function __construct(\WP_Rocket\Admin\Options_Data $options)
{
static $reflection;

if (! $this->valueHolder5c912) {
$reflection = $reflection ?? new \ReflectionClass('WP_Rocket\\Addon\\Sucuri\\Subscriber');
$this->valueHolder5c912 = $reflection->newInstanceWithoutConstructor();
\Closure::bind(function (\WP_Rocket\Addon\Sucuri\Subscriber $instance) {
unset($instance->options);
}, $this, 'WP_Rocket\\Addon\\Sucuri\\Subscriber')->__invoke($this);

}

$this->valueHolder5c912->__construct($options);
}

public function & __get($name)
{
$this->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, '__get', ['name' => $name], $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;

if (isset(self::$publicProperties3f2b9[$name])) {
return $this->valueHolder5c912->$name;
}

$realInstanceReflection = new \ReflectionClass('WP_Rocket\\Addon\\Sucuri\\Subscriber');

if (! $realInstanceReflection->hasProperty($name)) {
$targetObject = $this->valueHolder5c912;

$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->valueHolder5c912;
$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->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, '__set', array('name' => $name, 'value' => $value), $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;

$realInstanceReflection = new \ReflectionClass('WP_Rocket\\Addon\\Sucuri\\Subscriber');

if (! $realInstanceReflection->hasProperty($name)) {
$targetObject = $this->valueHolder5c912;

$targetObject->$name = $value;

return $targetObject->$name;
}

$targetObject = $this->valueHolder5c912;
$accessor = function & () use ($targetObject, $name, $value) {
$targetObject->$name = $value;

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->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, '__isset', array('name' => $name), $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;

$realInstanceReflection = new \ReflectionClass('WP_Rocket\\Addon\\Sucuri\\Subscriber');

if (! $realInstanceReflection->hasProperty($name)) {
$targetObject = $this->valueHolder5c912;

return isset($targetObject->$name);
}

$targetObject = $this->valueHolder5c912;
$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->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, '__unset', array('name' => $name), $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;

$realInstanceReflection = new \ReflectionClass('WP_Rocket\\Addon\\Sucuri\\Subscriber');

if (! $realInstanceReflection->hasProperty($name)) {
$targetObject = $this->valueHolder5c912;

unset($targetObject->$name);

return;
}

$targetObject = $this->valueHolder5c912;
$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->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, '__clone', array(), $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;

$this->valueHolder5c912 = clone $this->valueHolder5c912;
}

public function __sleep()
{
$this->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, '__sleep', array(), $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;

return array('valueHolder5c912');
}

public function __wakeup()
{
\Closure::bind(function (\WP_Rocket\Addon\Sucuri\Subscriber $instance) {
unset($instance->options);
}, $this, 'WP_Rocket\\Addon\\Sucuri\\Subscriber')->__invoke($this);
}

public function setProxyInitializer(\Closure $initializer = null) : void
{
$this->initializerb4055 = $initializer;
}

public function getProxyInitializer() : ?\Closure
{
return $this->initializerb4055;
}

public function initializeProxy() : bool
{
return $this->initializerb4055 && ($this->initializerb4055->__invoke($valueHolder5c912, $this, 'initializeProxy', array(), $this->initializerb4055) || 1) && $this->valueHolder5c912 = $valueHolder5c912;
}

public function isProxyInitialized() : bool
{
return null !== $this->valueHolder5c912;
}

public function getWrappedValueHolderValue()
{
return $this->valueHolder5c912;
}
}
Loading
Loading