(string $id, $concrete = null) { $id = static::normaliseAlias($id); $concrete = $concrete ?? $id; $this->alias = $id; $this->concrete = $concrete; } public function addTag(string $tag): DefinitionInterface { $this->tags[$tag] = true; return $this; } public function hasTag(string $tag): bool { return isset($this->tags[$tag]); } public function setAlias(string $id): DefinitionInterface { $id = static::normaliseAlias($id); $this->alias = $id; return $this; } public function getAlias(): string { return $this->alias; } public function setShared(bool $shared = true): DefinitionInterface { $this->shared = $shared; return $this; } public function isShared(): bool { return $this->shared; } public function getConcrete() { return $this->concrete; } public function setConcrete($concrete): DefinitionInterface { $this->concrete = $concrete; $this->resolved = null; return $this; } public function addArgument($arg): DefinitionInterface { $this->arguments[] = $arg; return $this; } public function addArguments(array $args): DefinitionInterface { foreach ($args as $arg) { $this->addArgument($arg); } return $this; } public function addMethodCall(string $method, array $args = []): DefinitionInterface { $this->methods[] = [ 'method' => $method, 'arguments' => $args ]; return $this; } public function addMethodCalls(array $methods = []): DefinitionInterface { foreach ($methods as $method => $args) { $this->addMethodCall($method, $args); } return $this; } public function resolve() { if (null !== $this->resolved && $this->isShared()) { return $this->resolved; } return $this->resolveNew(); } public function resolveNew() { $concrete = $this->concrete; if (is_callable($concrete)) { $concrete = $this->resolveCallable($concrete); } if ($concrete instanceof LiteralArgumentInterface) { $this->resolved = $concrete->getValue(); return $concrete->getValue(); } if ($concrete instanceof ArgumentInterface) { $concrete = $concrete->getValue(); } if (is_string($concrete)) { if (class_exists($concrete)) { $concrete = $this->resolveClass($concrete); } elseif ($this->getAlias() === $concrete) { return $concrete; } } if (is_object($concrete)) { $concrete = $this->invokeMethods($concrete); } try { $container = $this->getContainer(); } catch (ContainerException $e) { $container = null; } // if we still have a string, try to pull it from the container // this allows for `alias -> alias -> ... -> concrete if (is_string($concrete) && $container instanceof ContainerInterface && $container->has($concrete)) { $concrete = $container->get($concrete); } $this->resolved = $concrete; return $concrete; } /** * @param callable $concrete * @return mixed */ protected function resolveCallable(callable $concrete) { $resolved = $this->resolveArguments($this->arguments); return call_user_func_array($concrete, $resolved); } protected function resolveClass(string $concrete): object { $resolved = $this->resolveArguments($this->arguments); $reflection = new ReflectionClass($concrete); return $reflection->newInstanceArgs($resolved); } protected function invokeMethods(object $instance): object { foreach ($this->methods as $method) { $args = $this->resolveArguments($method['arguments']); $callable = [$instance, $method['method']]; call_user_func_array($callable, $args); } return $instance; } public static function normaliseAlias(string $alias): string { if (strpos($alias, '\\') === 0) { return substr($alias, 1); } return $alias; } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\Definition" not found in /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/DefinitionAggregate.php:30 Stack trace: #0 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/DefinitionAggregate.php(40): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\DefinitionAggregate->add('Automattic\\WooC...', Object(Automattic\WooCommerce\GoogleListingsAndAds\Container)) #1 /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Container.php(78): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Definition\DefinitionAggregate->addShared('Automattic\\WooC...', Object(Automattic\WooCommerce\GoogleListingsAndAds\Container)) #2 /htdocs/wp-content/plugins/google-listings-and-ads/src/Container.php(75): Automattic\WooCommerce\GoogleListingsAndAds\Vendor\League\Container\Container->addShared('Automattic\\WooC...', Object(Automattic\WooCommerce\GoogleListingsAndAds\Container)) #3 /htdocs/wp-content/plugins/google-listings-and-ads/google-listings-and-ads.php(101): Automattic\WooCommerce\GoogleListingsAndAds\Container->__construct() #4 /htdocs/wp-content/plugins/google-listings-and-ads/src/PluginFactory.php(25): woogle_get_container() #5 /htdocs/wp-content/plugins/google-listings-and-ads/google-listings-and-ads.php(75): Automattic\WooCommerce\GoogleListingsAndAds\PluginFactory::instance() #6 /htdocs/wp-includes/class-wp-hook.php(353): {closure}('') #7 /htdocs/wp-includes/class-wp-hook.php(377): WP_Hook->apply_filters('', Array) #8 /htdocs/wp-includes/plugin.php(523): WP_Hook->do_action(Array) #9 /htdocs/wp-content/plugins/woocommerce/includes/class-woocommerce.php(288): do_action('woocommerce_loa...') #10 /htdocs/wp-includes/class-wp-hook.php(353): WooCommerce->on_plugins_loaded('') #11 /htdocs/wp-includes/class-wp-hook.php(377): WP_Hook->apply_filters(NULL, Array) #12 /htdocs/wp-includes/plugin.php(523): WP_Hook->do_action(Array) #13 /htdocs/wp-settings.php(630): do_action('plugins_loaded') #14 /htdocs/wp-config.php(113): require_once('/htdocs/wp-sett...') #15 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #16 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #17 /htdocs/index.php(17): require('/htdocs/wp-blog...') #18 {main} thrown in /htdocs/wp-content/plugins/google-listings-and-ads/vendor/league/container/src/Definition/DefinitionAggregate.php on line 30