Removed the php version check. (#5850)

This commit is contained in:
李铭昕 2023-06-18 19:54:50 +08:00 committed by GitHub
parent 2958364104
commit 67236750b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 20 additions and 50 deletions

View File

@ -49,7 +49,6 @@ class PhpParserTest extends TestCase
$this->assertSame(['', 'HyperfTest', 'CodeParser', 'Stub', 'Foo'], $foo2->type->parts);
$this->assertNodeParam($extra, $parser->getNodeFromReflectionParameter($parameters[2]));
if (PHP_VERSION_ID > 80000) {
$stmts = $parser7->parse(file_get_contents(__DIR__ . '/Stub/UnionTypeFoo.php'));
/** @var ClassMethod $classMethod */
$classMethod = $stmts[1]->stmts[0]->stmts[0];
@ -59,14 +58,9 @@ class PhpParserTest extends TestCase
$parameters = $foo->getMethod('__construct')->getParameters();
$this->assertNodeParam($name, $parser->getNodeFromReflectionParameter($parameters[0]));
}
}
public function testGetExprFromEnum()
{
if (PHP_VERSION_ID < 80100) {
$this->markTestSkipped('The version below 8.1 does not support enum.');
}
$parser = new PhpParser();
$printer = new Standard();

View File

@ -11,9 +11,7 @@ declare(strict_types=1);
*/
namespace HyperfTest\CodeParser\Stub;
if (PHP_VERSION_ID > 80100) {
enum FooEnum: int
{
case DEFAULT = 1;
}
}

View File

@ -15,8 +15,6 @@ use BackedEnum;
use Hyperf\Stringable\Str;
use ReflectionClassConstant;
use const PHP_VERSION_ID;
class AnnotationReader
{
/**
@ -27,12 +25,10 @@ class AnnotationReader
$result = [];
foreach ($classConstants as $classConstant) {
$code = $classConstant->getValue();
if (PHP_VERSION_ID >= 80100) {
/* @phpstan-ignore-next-line */
if ($classConstant->isEnumCase()) {
$code = $code instanceof BackedEnum ? $code->value : $code->name;
}
}
$docComment = $classConstant->getDocComment();
// Not support float and bool, because it will be convert to int.
if ($docComment && (is_int($code) || is_string($code))) {

View File

@ -127,10 +127,6 @@ class Par2 extends Par
public function testAstProxyForEnum()
{
if (PHP_VERSION_ID < 80100) {
$this->markTestSkipped('The version below 8.1 does not support enum.');
}
$ast = new Ast();
$code = $ast->proxy(FooEnumStruct::class);

View File

@ -11,9 +11,7 @@ declare(strict_types=1);
*/
namespace HyperfTest\Di\Stub;
if (PHP_VERSION_ID > 80100) {
enum FooEnum: int
{
case DEFAULT = 1;
}
}

View File

@ -179,15 +179,9 @@ class StrTest extends TestCase
$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('<strong>before</strong><br>after', Str::stripTags('<strong>before</strong><br>after', '<br><strong>'));
if (PHP_VERSION_ID >= 70400) {
$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()
{

View File

@ -101,15 +101,9 @@ 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('<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>'));
if (PHP_VERSION_ID >= 70400) {
$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()
{