limingxinleo/swoft-trait-instance

基于Swoft的协程单例扩展

1.0.1 2018-08-20 11:00 UTC

This package is auto-updated.

Last update: 2021-09-17 12:32:49 UTC


README

基于Swoft的协程单例扩展

Build Status

单例模式Trait

<?php
use Xin\Swoft\Traits\InstanceTrait;

class Incr
{
    use InstanceTrait;

    public $incr = 0;

    public function incr()
    {
        return ++$this->incr;
    }

    public function get()
    {
        return $this->incr;
    }
}

echo Incr::getInstance()->incr(); // 1
go(function(){
    echo Incr::getInstance()->incr(); // 1
});