public function with(ObjectInterface $object): self
    {
        $clone = clone $this;
        $clone->objects[$object->getId()] = $object;
        $clone->array[$object->getId()] = $object->getInstance();

        return $clone;
    }
public function with(ObjectInterface $object): self
    {
        $clone = clone $this;
        $clone->objects[$object->getId()] = $object;
        $clone->array[$object->getId()] = $object->getInstance();

        return $clone;
    }
public function with ( ObjectInterface $ object ) : self { $ clone = clone $ this ; $ clone -> objects [ $ object -> getId ( ) ] = $ object ; $ clone -> array [ $ object -> getId ( ) ] = $ object -> getInstance ( ) ; return $ clone ; }
Creates a new instance which will contain the given object. If an object with the same reference already exists,
it will be overridden by the new object.
Creates a new instance which will contain the given object . If an object with the same reference already exists it will be overridden by the new object .