1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-02 09:37:59 +01:00

ambiguous php version checks (#4331)

This commit is contained in:
orklah 2020-10-15 02:00:50 +02:00 committed by Daniil Gentili
parent 91e8e26937
commit 3ed70e3ca0
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
4 changed files with 10 additions and 4 deletions

View File

@ -10,7 +10,9 @@ class TAnonymousClassInstance extends TNamedObject
int $php_major_version, int $php_major_version,
int $php_minor_version int $php_minor_version
): ?string { ): ?string {
return $php_major_version >= 7 && $php_minor_version >= 2 ? 'object' : null; return $php_major_version > 7
|| ($php_major_version === 7 && $php_minor_version >= 2)
? 'object' : null;
} }
/** /**

View File

@ -23,7 +23,9 @@ class TCallableObject extends TObject
int $php_major_version, int $php_major_version,
int $php_minor_version int $php_minor_version
): ?string { ): ?string {
return $php_major_version >= 7 && $php_minor_version >= 2 ? 'object' : null; return $php_major_version > 7
|| ($php_major_version === 7 && $php_minor_version >= 2)
? 'object' : null;
} }
public function canBeFullyExpressedInPhp(): bool public function canBeFullyExpressedInPhp(): bool

View File

@ -23,7 +23,9 @@ class TVoid extends \Psalm\Type\Atomic
int $php_major_version, int $php_major_version,
int $php_minor_version int $php_minor_version
): ?string { ): ?string {
return $php_major_version >= 7 && $php_minor_version >= 1 ? $this->getKey() : null; return $php_major_version > 7
|| ($php_major_version === 7 && $php_minor_version >= 1)
? $this->getKey() : null;
} }
public function canBeFullyExpressedInPhp(): bool public function canBeFullyExpressedInPhp(): bool

View File

@ -452,7 +452,7 @@ class Union implements TypeNode
if (!$this->isSingleAndMaybeNullable() if (!$this->isSingleAndMaybeNullable()
|| $php_major_version < 7 || $php_major_version < 7
|| (isset($this->types['null']) && $php_minor_version < 1) || (isset($this->types['null']) && $php_major_version === 7 && $php_minor_version < 1)
) { ) {
return null; return null;
} }