WordPress at Your Fingertips
function is not described

Automattic\WooCommerce\Internal\DependencyManagement

ExtendedContainer::replace() public WC 1.0

Replace an existing registration with a different concrete.

{} It's a method of the class: ExtendedContainer{}

No Hooks.

Return

DefinitionInterface. The modified definition.

Usage

$ExtendedContainer = new ExtendedContainer();
$ExtendedContainer->replace( $class_name, $concrete ) : DefinitionInterface;
$class_name(string) (required)
The class name whose definition will be replaced.
$concrete(mixed) (required)
The new concrete (same as "add").

Code of ExtendedContainer::replace() WC 5.9.0

public function replace( string $class_name, $concrete ) : DefinitionInterface {
	if ( ! $this->has( $class_name ) ) {
		throw new ContainerException( "The container doesn't have '$class_name' registered, please use 'add' instead of 'replace'." );
	}

	$concrete_class = $this->get_class_from_concrete( $concrete );
	if ( isset( $concrete_class ) && ! $this->is_class_allowed( $concrete_class ) && ! $this->is_anonymous_class( $concrete_class ) ) {
		throw new ContainerException( "You cannot use concrete '$concrete_class', only classes in the {$this->woocommerce_namespace} namespace are allowed." );
	}

	return $this->extend( $class_name )->setConcrete( $concrete );
}