Public function to set the instance.

@return object
547293
public static function run()
    {
        if (! isset(self::$instance)) {
            self::$instance = new self();

            self::$instance->setup();
            self::$instance->execute();
            self::$instance->hooks();
            self::$instance->ajax();
        }

        return self::$instance;
    }
766334
static public function instance()
    {
        $key = get_called_class();
        if (!isset(static::$instances[$key])) {
            $object = new static();
            $object->setCache(Ioc::cache('widget'));
            static::$instances[$key] = $object;
        }
        return static::$instances[$key];
    }
813078
public static function setInstance($instance = "") {
		
		if (empty($instance) || !method_exists($instance,'addGlobal')) {
			Console::writeError("please set the instance");
		}
		
		self::$instance = $instance;

	}
378259
public static function getInstance()
    {
        if (is_null(self::$instance)) {
            throw new \RuntimeException('You must first create the singleton instance with createInstance().');
        }
        self::$instance->setGlobalsFromSugar();
        self::$instance->chdirToSugarDir();

        return self::$instance;
    }
1256084
public function instance()
    {
        if (isset(self::$instances[$this->recordCode])) {
            return self::$instances[$this->recordCode];
        }

        if (!$item = $this->getSettingsRecord()) {
            $this->model->initSettingsData();
            $item = $this->model;
        }

        return self::$instances[$this->recordCode] = $item;
    }
1078663
public function create()
    {
        $instance = self::createOrderLineItem($this);
        $this->setId($instance->getId());
        return $instance;
    }
5065
public static function getInstance() {

		if( !isset( self::$instance ) ) {

			self::$instance	= new CoreProperties();

			self::$instance->init( CoreGlobal::CONFIG_CORE );
		}

		return self::$instance;
	}
69538
public static function instance(): self
    {
        if (!self::$instance) {
            self::$instance = new self(
                Sequencer::sequence('event-sequence-number'),
                SystemClock::instance()
            );
        }

        return self::$instance;
    }
1257397
private static function instance()
    {
        $currentClass = get_called_class();
        $instanceName = empty( self::$instance ) ? '' : new \ReflectionClass(self::$instance);
        if( empty( self::$instance ) || ( $instanceName->name != $currentClass ) ) {
            self::$instance = new static();
        }
        return self::$instance;
    }
1327223
static function GetInstance()
	{
		if (!self::$IS_INITIALIZED) self::Init();

		if (!self::$INSTANCE instanceof self) self::$INSTANCE = new self;

		return self::$INSTANCE;
	}
1291169
public function &getInstance()
    {
        if (empty($this->instance)) {
            $className = $this->name;
            $this->instance = new $className();

            if (count($this->properties)) {
                foreach ($this->properties as $key => $value) {
                    $setterMethodName = camelcase('set_' . $key);

                    if (method_exists($this->instance, $setterMethodName)) {
                        $this->instance->{$setterMethodName}($value);
                    } else {
                        $this->instance->{$key} = $value;
                    }
                }
            }
        }

        return $this->instance;
    }
1161919
public static function GetInstance() {
      if (!isset(self::$_Instance)) {
         $c = __CLASS__;
         self::$_Instance = new $c();
      }
      return self::$_Instance;
   }
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);
            }
        }
    }
1331148
public function create()
    {
        $instance = self::createCategory($this);
        $this->setId($instance->getId());
        return $instance;
    }
1334691
private static function initInstance(): Instance
    {
        $instance = new Instance();
        $instance->setOptions(Config::get('translator'));
        $instance->init();
        return $instance;
    }
811004
public static function &getInstance()
    {
        $classname = get_called_class();
        if (!isset(self::$_instances[ $classname ])) {
            self::createInstance($classname, func_get_args());
        }
        $instance = self::$_instances[ $classname ];
        return $instance;
    }
747584
public function create()
    {
        $instance = self::createCustomer($this);
        $this->setId($instance->getId());
        return $instance;
    }