Skip to content

Commit

Permalink
修复 static 类型的解析处理
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurunsoft committed Oct 16, 2023
1 parent 5d2eeb9 commit 9a6852c
Show file tree
Hide file tree
Showing 7 changed files with 301 additions and 289 deletions.
10 changes: 7 additions & 3 deletions src/Bean/ReflectionUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public static function getTypeComments(?\ReflectionType $type, ?string $classNam
$typeStr = '\\' . $className;
}
}
else
elseif ('static' !== $typeStr)
{
$typeStr = '\\' . $typeStr;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ public static function getTypeCode(?\ReflectionType $type, ?string $className =
$typeStr = '\\' . $className;
}
}
else
elseif ('static' !== $typeStr)
{
$typeStr = '\\' . $typeStr;
}
Expand Down Expand Up @@ -172,9 +172,13 @@ public static function allowsType(\ReflectionType $type, string $checkType, ?str
{
if (null !== $className)
{
$typeStr = $className;
$typeStr = '\\' . $className;
}
}
elseif ('static' !== $typeStr)
{
$typeStr = '\\' . $typeStr;
}
}

return $typeStr === $checkType || \in_array($typeStr, $checkTypes) || is_subclass_of($checkType, $typeStr);
Expand Down
6 changes: 5 additions & 1 deletion src/Facade/Cli/FacadeGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,14 @@ public function generate(string $facadeClass, string $class, bool $request): voi
if (false !== $docComment && preg_match('/@return\s+([^\s]+)/', $docComment, $matches) > 0)
{
$class = $matches[1];
if ('self' === $class || 'static' === $class)
if ('self' === $class)
{
$returnType = '\\' . $method->getDeclaringClass()->getName();
}
elseif ('static' === $class)
{
$returnType = 'static';
}
elseif ('\\' === $class[0])
{
$returnType = $class;
Expand Down
6 changes: 5 additions & 1 deletion src/RequestContextProxy/Cli/RequestContextProxyGenerate.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,14 @@ public function generate(string $target, string $class, string $name, ?string $b
if (false !== $docComment && preg_match('/@return\s+([^\s]+)/', $docComment, $matches) > 0)
{
$class = $matches[1];
if ('self' === $class || 'static' === $class)
if ('self' === $class)
{
$returnType = '\\' . $method->getDeclaringClass()->getName();
}
elseif ('static' === $class)
{
$returnType = 'static';
}
elseif ('\\' === $class[0])
{
$returnType = $class;
Expand Down
220 changes: 110 additions & 110 deletions src/Server/Http/Message/Proxy/RequestProxy.php

Large diffs are not rendered by default.

220 changes: 110 additions & 110 deletions src/Server/Http/Message/Proxy/RequestProxyObject.php

Large diffs are not rendered by default.

64 changes: 32 additions & 32 deletions src/Server/Http/Message/Proxy/ResponseProxy.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
* @method static \Imi\Server\Http\Message\Contract\IHttpResponse setResponseBodyEmitter(?\Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter $responseBodyEmitter)
* @method \Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter|null getResponseBodyEmitter()
* @method static \Imi\Server\Http\Message\Emitter\Contract\IResponseBodyEmitter|null getResponseBodyEmitter()
* @method \Imi\Util\Http\Contract\IResponse setStatus(int $code, string $reasonPhrase = '')
* @method static \Imi\Util\Http\Contract\IResponse setStatus(int $code, string $reasonPhrase = '')
* @method \Imi\Util\Http\Contract\IResponse withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false)
* @method static \Imi\Util\Http\Contract\IResponse withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false)
* @method \Imi\Util\Http\Contract\IResponse setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false)
* @method static \Imi\Util\Http\Contract\IResponse setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false)
* @method static setStatus(int $code, string $reasonPhrase = '')
* @method static static setStatus(int $code, string $reasonPhrase = '')
* @method static withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false)
* @method static static withCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false)
* @method static setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false)
* @method static static setCookie(string $key, string $value, int $expire = 0, string $path = '/', string $domain = '', bool $secure = false, bool $httponly = false)
* @method array getCookieParams()
* @method static array getCookieParams()
* @method mixed getCookie(string $name, $default = NULL)
Expand All @@ -42,20 +42,20 @@
* @method static bool hasTrailer(string $name)
* @method string|null getTrailer(string $name)
* @method static string|null getTrailer(string $name)
* @method \Imi\Util\Http\Contract\IResponse withTrailer(string $name, string $value)
* @method static \Imi\Util\Http\Contract\IResponse withTrailer(string $name, string $value)
* @method \Imi\Util\Http\Contract\IResponse setTrailer(string $name, string $value)
* @method static \Imi\Util\Http\Contract\IResponse setTrailer(string $name, string $value)
* @method static withTrailer(string $name, string $value)
* @method static static withTrailer(string $name, string $value)
* @method static setTrailer(string $name, string $value)
* @method static static setTrailer(string $name, string $value)
* @method int getStatusCode()
* @method static int getStatusCode()
* @method \Psr\Http\Message\ResponseInterface withStatus($code, $reasonPhrase = '')
* @method static \Psr\Http\Message\ResponseInterface withStatus($code, $reasonPhrase = '')
* @method static withStatus($code, $reasonPhrase = '')
* @method static static withStatus($code, $reasonPhrase = '')
* @method string getReasonPhrase()
* @method static string getReasonPhrase()
* @method string getProtocolVersion()
* @method static string getProtocolVersion()
* @method \Psr\Http\Message\MessageInterface withProtocolVersion($version)
* @method static \Psr\Http\Message\MessageInterface withProtocolVersion($version)
* @method static withProtocolVersion($version)
* @method static static withProtocolVersion($version)
* @method string[][] getHeaders()
* @method static string[][] getHeaders()
* @method bool hasHeader($name)
Expand All @@ -64,26 +64,26 @@
* @method static string[] getHeader($name)
* @method string getHeaderLine($name)
* @method static string getHeaderLine($name)
* @method \Psr\Http\Message\MessageInterface withHeader($name, $value)
* @method static \Psr\Http\Message\MessageInterface withHeader($name, $value)
* @method \Psr\Http\Message\MessageInterface withAddedHeader($name, $value)
* @method static \Psr\Http\Message\MessageInterface withAddedHeader($name, $value)
* @method \Psr\Http\Message\MessageInterface withoutHeader($name)
* @method static \Psr\Http\Message\MessageInterface withoutHeader($name)
* @method static withHeader($name, $value)
* @method static static withHeader($name, $value)
* @method static withAddedHeader($name, $value)
* @method static static withAddedHeader($name, $value)
* @method static withoutHeader($name)
* @method static static withoutHeader($name)
* @method \Psr\Http\Message\StreamInterface getBody()
* @method static \Psr\Http\Message\StreamInterface getBody()
* @method \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body)
* @method static \Psr\Http\Message\MessageInterface withBody(\Psr\Http\Message\StreamInterface $body)
* @method \Imi\Util\Http\Contract\IMessage setProtocolVersion(string $version)
* @method static \Imi\Util\Http\Contract\IMessage setProtocolVersion(string $version)
* @method \Imi\Util\Http\Contract\IMessage setHeader(string $name, $value)
* @method static \Imi\Util\Http\Contract\IMessage setHeader(string $name, $value)
* @method \Imi\Util\Http\Contract\IMessage addHeader(string $name, $value)
* @method static \Imi\Util\Http\Contract\IMessage addHeader(string $name, $value)
* @method \Imi\Util\Http\Contract\IMessage removeHeader(string $name)
* @method static \Imi\Util\Http\Contract\IMessage removeHeader(string $name)
* @method \Imi\Util\Http\Contract\IMessage setBody(\Psr\Http\Message\StreamInterface $body)
* @method static \Imi\Util\Http\Contract\IMessage setBody(\Psr\Http\Message\StreamInterface $body)
* @method static withBody(\Psr\Http\Message\StreamInterface $body)
* @method static static withBody(\Psr\Http\Message\StreamInterface $body)
* @method static setProtocolVersion(string $version)
* @method static static setProtocolVersion(string $version)
* @method static setHeader(string $name, $value)
* @method static static setHeader(string $name, $value)
* @method static addHeader(string $name, $value)
* @method static static addHeader(string $name, $value)
* @method static removeHeader(string $name)
* @method static static removeHeader(string $name)
* @method static setBody(\Psr\Http\Message\StreamInterface $body)
* @method static static setBody(\Psr\Http\Message\StreamInterface $body)
*/
class ResponseProxy extends BaseRequestContextProxy
{
Expand Down
Loading

0 comments on commit 9a6852c

Please sign in to comment.