Instance setter

@param string $className Class name
@param object $instance  Object instance

@static

@return null
518368
public static function set($className, $instance)
    {
        $key = self::getStorageKey($className);

        if (is_null($instance)) {
            unset(self::$instances[$key]);

            return;
        }

        self::$instances[$key] = $instance;

        return;
    }
958298
private function getPropValue($instance, $fieldName)
    {
        $field = $this->getField($instance, $fieldName);
        $field->setAccessible(true);
        return $field->getValue($instance);
    }
712006
private static function set( $instance = false ) {
		// Make sure the plugin hasn't already been instantiated before.
		global $wp_plugins;
		if ( ! isset( $wp_plugins ) ) {
			$wp_plugins = new \stdClass();
		}
		// Get the fully qualified parent class name and instantiate an instance of it.
		$called_class = get_called_class();
		$plugin_name  = strtolower( $called_class );
		if ( empty( $instance ) || ! is_a( $instance, $called_class ) ) {
			$wp_plugins->$plugin_name = new $called_class();
		} else {
			$wp_plugins->$plugin_name = $instance;
		}
	}
986896
public function unsetParameter($instanceName, $paramName) {
		unset($this->declaredInstances[$instanceName]['fieldProperties'][$paramName]);
		unset($this->declaredInstances[$instanceName]['fieldBinds'][$paramName]);
	}
602697
public function getParameterTypeForSetter($instanceName, $setterName) {
		if (isset($this->declaredInstances[$instanceName]['setterProperties'][$setterName]['type'])) {
			return $this->declaredInstances[$instanceName]['setterProperties'][$setterName]['type'];
		} else {
			return null;
		}
	}
312944
public static function resetInstance(): void
    {
        $name = self::$instancePropertyName;
        if (is_object(self::$$name)) {
            if (self::$$name->allowToResetInstance) {
                self::$$name = null;
            } else {
                throw new \RuntimeException(
                    "Resetting of singleton instance disallowed"
                );
            }
        }
    }
633791
public function alterClass($instanceName, $className) {
        if (!isset($this->declaredInstances[$instanceName])) {
            throw new MoufInstanceNotFoundException("Unable to find instance '".$instanceName."'.");
        }
        $this->declaredInstances[$instanceName]["class"] = $className;
    }
925102
public static function instance( $className = null )
    {
        if ( is_null( $className ) )
        {
            $ini = eZINI::instance( 'ezcomments.ini' );
            $className = $ini->variable( 'NotificationSettings', 'NotificationManagerClass' );
        }
        if ( !isset( self::$instance ) )
        {
            self::$instance = new $className();
        }
        return self::$instance;
    }
1030275
public function getParameterForSetter($instanceName, $setterName) {
		// todo: improve this
		if (isset($this->declaredInstances[$instanceName]['setterProperties'][$setterName]['value'])) {
			return $this->declaredInstances[$instanceName]['setterProperties'][$setterName]['value'];
		} else {
			return null;
		}
	}
809072
public function setClassName(string $className): self
    {
        if (!class_exists($className)) {
            throw new \InvalidArgumentException(sprintf(
                'Class %s does not exist',
                $className
            ));
        }
        $this->className = $className;

        return $this;
    }
485620
public function isParameterSet($instanceName, $paramName) {
		return isset($this->declaredInstances[$instanceName]['fieldProperties'][$paramName]) || isset($this->declaredInstances[$instanceName]['fieldBinds'][$paramName]);
	}
762347
public function buildObject($instance = null)
    {
        if (is_null($instance)) {
            return (object) $this->fields;
        }
        foreach ($this->fields as $property => $value) {
            $method = 'set' . ucwords($property);
            if (is_callable([$instance, $method])) {
                $instance->{$method}($value);
            }
        }
    }
86902
public function isInstanceOf($className)
    {
        $this->doCheck(function ($value) use ($className) {
            $this->throwExceptionIfFalse(
                $value instanceof $className,
                'Failed assertion that %s is an instance of %s', $value, $className
            );
        });

        return $this;
    }
46268
public function setInstance(Instance $instance)
    {
        $this->instance = $instance;
        $this->exception = null;
        $this->connect();
        
        return $this;
    }
900696
private static function createInstance($classname, array $arguments = array())
    {
        $reflection_obj = new ReflectionClass($classname);
        if ($reflection_obj->getMethod('__construct')->isPublic()) {
            self::$_instances[ $classname ] = call_user_func_array(array($reflection_obj, 'newInstance'), $arguments);
            if (
                method_exists(self::$_instances[ $classname ], 'init') &&
                is_callable(array(self::$_instances[ $classname ], 'init'))
            ) {
                self::$_instances[ $classname ]->init();
            }
        } else {
            self::$_instances[ $classname ] = new $classname;
            if (
                method_exists(self::$_instances[ $classname ], 'init') &&
                is_callable(array(self::$_instances[ $classname ], 'init'))
            ) {
                call_user_func_array(array(self::$_instances[ $classname ], 'init'), $arguments);
            }
        }
    }
783160
public function getCode($instanceName) {
		if (isset($this->declaredInstances[$instanceName]["code"])) {
			return $this->declaredInstances[$instanceName]["code"];
		}
		return null;
	}
206897
public function removeInstance($className): self
	{
		// Determine the instance name
		$instanceName = strtolower($className);

		if (!isset($this->{$instanceName}))
		{
			throw new FactoryException("Could not remove instance of '".$instanceName."'. Instance was not found.", 1);
		}

		// Unset
		unset($this->{$instanceName});

		// Return itself
		return $this;
	}