Skip to content

Commit

Permalink
fix: swoft-cloud/swoft#1083 uniqid is not work on cygwin
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Nov 5, 2019
1 parent c466f6a commit c7f688f
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/rpc-client/src/Proxy.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
<?php declare(strict_types=1);


namespace Swoft\Rpc\Client;


use Swoft\Proxy\Exception\ProxyException;
use Swoft\Proxy\Proxy as BaseProxy;
use Swoft\Rpc\Client\Exception\RpcClientException;
use Swoft\Rpc\Client\Proxy\Ast\ProxyVisitor;
use Swoft\Stdlib\Helper\Str;

/**
* Class Proxy
*
* @since 2.0
*/
class Proxy
{
/**
Expand All @@ -32,4 +35,4 @@ public static function newClassName(string $className): string
$className = BaseProxy::newClassName($className, $visitor);
return $className;
}
}
}
13 changes: 13 additions & 0 deletions src/stdlib/src/Concern/RandomStringTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php declare(strict_types=1);

namespace Swoft\Stdlib\Concern;

/**
* Trait RandomStringTrait
*
* @since 2.0.7
*/
trait RandomStringTrait
{

}
14 changes: 10 additions & 4 deletions src/stdlib/src/Helper/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,17 @@ public static function rmPharPrefix(string $path): string
*
* @return string
*/
public static function getUniqid(string $prefix = "", bool $moreEntropy = false): string
public static function getUniqid(string $prefix = '', bool $moreEntropy = false): string
{
$uniqid = uniqid($prefix, $moreEntropy);
$uniqid = str_replace('.', '', $uniqid);
return $uniqid;
// If on Cygwin, $moreEntropy must be TRUE.
if (EnvHelper::isCygwin()) {
$moreEntropy = true;
}

$uniqId = uniqid($prefix, $moreEntropy);
$uniqId = str_replace('.', '', $uniqId);

return $uniqId;
}

/**
Expand Down

0 comments on commit c7f688f

Please sign in to comment.