mirror of
https://gitee.com/hyperf/hyperf.git
synced 2024-12-02 03:37:44 +08:00
Removed the php version check. (#5850)
This commit is contained in:
parent
2958364104
commit
67236750b2
@ -49,24 +49,18 @@ class PhpParserTest extends TestCase
|
|||||||
$this->assertSame(['', 'HyperfTest', 'CodeParser', 'Stub', 'Foo'], $foo2->type->parts);
|
$this->assertSame(['', 'HyperfTest', 'CodeParser', 'Stub', 'Foo'], $foo2->type->parts);
|
||||||
$this->assertNodeParam($extra, $parser->getNodeFromReflectionParameter($parameters[2]));
|
$this->assertNodeParam($extra, $parser->getNodeFromReflectionParameter($parameters[2]));
|
||||||
|
|
||||||
if (PHP_VERSION_ID > 80000) {
|
$stmts = $parser7->parse(file_get_contents(__DIR__ . '/Stub/UnionTypeFoo.php'));
|
||||||
$stmts = $parser7->parse(file_get_contents(__DIR__ . '/Stub/UnionTypeFoo.php'));
|
/** @var ClassMethod $classMethod */
|
||||||
/** @var ClassMethod $classMethod */
|
$classMethod = $stmts[1]->stmts[0]->stmts[0];
|
||||||
$classMethod = $stmts[1]->stmts[0]->stmts[0];
|
$name = $classMethod->getParams()[0];
|
||||||
$name = $classMethod->getParams()[0];
|
|
||||||
|
|
||||||
$foo = new ReflectionClass(UnionTypeFoo::class);
|
$foo = new ReflectionClass(UnionTypeFoo::class);
|
||||||
$parameters = $foo->getMethod('__construct')->getParameters();
|
$parameters = $foo->getMethod('__construct')->getParameters();
|
||||||
$this->assertNodeParam($name, $parser->getNodeFromReflectionParameter($parameters[0]));
|
$this->assertNodeParam($name, $parser->getNodeFromReflectionParameter($parameters[0]));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testGetExprFromEnum()
|
public function testGetExprFromEnum()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 80100) {
|
|
||||||
$this->markTestSkipped('The version below 8.1 does not support enum.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$parser = new PhpParser();
|
$parser = new PhpParser();
|
||||||
$printer = new Standard();
|
$printer = new Standard();
|
||||||
|
|
||||||
|
@ -11,9 +11,7 @@ declare(strict_types=1);
|
|||||||
*/
|
*/
|
||||||
namespace HyperfTest\CodeParser\Stub;
|
namespace HyperfTest\CodeParser\Stub;
|
||||||
|
|
||||||
if (PHP_VERSION_ID > 80100) {
|
enum FooEnum: int
|
||||||
enum FooEnum: int
|
{
|
||||||
{
|
case DEFAULT = 1;
|
||||||
case DEFAULT = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,6 @@ use BackedEnum;
|
|||||||
use Hyperf\Stringable\Str;
|
use Hyperf\Stringable\Str;
|
||||||
use ReflectionClassConstant;
|
use ReflectionClassConstant;
|
||||||
|
|
||||||
use const PHP_VERSION_ID;
|
|
||||||
|
|
||||||
class AnnotationReader
|
class AnnotationReader
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
@ -27,12 +25,10 @@ class AnnotationReader
|
|||||||
$result = [];
|
$result = [];
|
||||||
foreach ($classConstants as $classConstant) {
|
foreach ($classConstants as $classConstant) {
|
||||||
$code = $classConstant->getValue();
|
$code = $classConstant->getValue();
|
||||||
if (PHP_VERSION_ID >= 80100) {
|
if ($classConstant->isEnumCase()) {
|
||||||
/* @phpstan-ignore-next-line */
|
$code = $code instanceof BackedEnum ? $code->value : $code->name;
|
||||||
if ($classConstant->isEnumCase()) {
|
|
||||||
$code = $code instanceof BackedEnum ? $code->value : $code->name;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$docComment = $classConstant->getDocComment();
|
$docComment = $classConstant->getDocComment();
|
||||||
// Not support float and bool, because it will be convert to int.
|
// Not support float and bool, because it will be convert to int.
|
||||||
if ($docComment && (is_int($code) || is_string($code))) {
|
if ($docComment && (is_int($code) || is_string($code))) {
|
||||||
|
@ -127,10 +127,6 @@ class Par2 extends Par
|
|||||||
|
|
||||||
public function testAstProxyForEnum()
|
public function testAstProxyForEnum()
|
||||||
{
|
{
|
||||||
if (PHP_VERSION_ID < 80100) {
|
|
||||||
$this->markTestSkipped('The version below 8.1 does not support enum.');
|
|
||||||
}
|
|
||||||
|
|
||||||
$ast = new Ast();
|
$ast = new Ast();
|
||||||
$code = $ast->proxy(FooEnumStruct::class);
|
$code = $ast->proxy(FooEnumStruct::class);
|
||||||
|
|
||||||
|
@ -11,9 +11,7 @@ declare(strict_types=1);
|
|||||||
*/
|
*/
|
||||||
namespace HyperfTest\Di\Stub;
|
namespace HyperfTest\Di\Stub;
|
||||||
|
|
||||||
if (PHP_VERSION_ID > 80100) {
|
enum FooEnum: int
|
||||||
enum FooEnum: int
|
{
|
||||||
{
|
case DEFAULT = 1;
|
||||||
case DEFAULT = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -179,14 +179,8 @@ class StrTest extends TestCase
|
|||||||
$this->assertSame('before<br>after', Str::stripTags('before<br>after', '<br>'));
|
$this->assertSame('before<br>after', Str::stripTags('before<br>after', '<br>'));
|
||||||
$this->assertSame('before<br>after', Str::stripTags('<strong>before</strong><br>after', '<br>'));
|
$this->assertSame('before<br>after', Str::stripTags('<strong>before</strong><br>after', '<br>'));
|
||||||
$this->assertSame('<strong>before</strong><br>after', Str::stripTags('<strong>before</strong><br>after', '<br><strong>'));
|
$this->assertSame('<strong>before</strong><br>after', Str::stripTags('<strong>before</strong><br>after', '<br><strong>'));
|
||||||
|
$this->assertSame('<strong>before</strong><br>after', Str::stripTags('<strong>before</strong><br>after', ['<br>', '<strong>']));
|
||||||
if (PHP_VERSION_ID >= 70400) {
|
$this->assertSame('beforeafter', Str::stripTags('before<br>after', null));
|
||||||
$this->assertSame('<strong>before</strong><br>after', Str::stripTags('<strong>before</strong><br>after', ['<br>', '<strong>']));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 80000) {
|
|
||||||
$this->assertSame('beforeafter', Str::stripTags('before<br>after', null));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testPadBoth()
|
public function testPadBoth()
|
||||||
|
@ -101,14 +101,8 @@ class StringableTest extends TestCase
|
|||||||
$this->assertSame('before<br>after', (string) $this->stringable('before<br>after')->stripTags('<br>'));
|
$this->assertSame('before<br>after', (string) $this->stringable('before<br>after')->stripTags('<br>'));
|
||||||
$this->assertSame('before<br>after', (string) $this->stringable('<strong>before</strong><br>after')->stripTags('<br>'));
|
$this->assertSame('before<br>after', (string) $this->stringable('<strong>before</strong><br>after')->stripTags('<br>'));
|
||||||
$this->assertSame('<strong>before</strong><br>after', (string) $this->stringable('<strong>before</strong><br>after')->stripTags('<br><strong>'));
|
$this->assertSame('<strong>before</strong><br>after', (string) $this->stringable('<strong>before</strong><br>after')->stripTags('<br><strong>'));
|
||||||
|
$this->assertSame('<strong>before</strong><br>after', (string) $this->stringable('<strong>before</strong><br>after')->stripTags(['<br>', '<strong>']));
|
||||||
if (PHP_VERSION_ID >= 70400) {
|
$this->assertSame('beforeafter', (string) $this->stringable('before<br>after')->stripTags(null));
|
||||||
$this->assertSame('<strong>before</strong><br>after', (string) $this->stringable('<strong>before</strong><br>after')->stripTags(['<br>', '<strong>']));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PHP_VERSION_ID >= 80000) {
|
|
||||||
$this->assertSame('beforeafter', (string) $this->stringable('before<br>after')->stripTags(null));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testWhenEmptyAndNot()
|
public function testWhenEmptyAndNot()
|
||||||
|
Loading…
Reference in New Issue
Block a user