1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Fix #4350 - numeric-string should not get replaced

This commit is contained in:
Matt Brown 2020-10-16 17:11:37 -04:00 committed by Daniil Gentili
parent 3a8b8e5c2a
commit 426a1ce47e
Signed by: danog
GPG Key ID: 8C1BE3B34B230CA7
4 changed files with 39 additions and 13 deletions

View File

@ -3,19 +3,6 @@ namespace Psalm\Type\Atomic;
abstract class Scalar extends \Psalm\Type\Atomic
{
/**
* @param array<string> $aliased_classes
*/
public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
int $php_major_version,
int $php_minor_version
): ?string {
return $php_major_version >= 7 ? $this->getKey() : null;
}
public function canBeFullyExpressedInPhp(): bool
{
return true;

View File

@ -12,4 +12,17 @@ class TFloat extends Scalar
{
return 'float';
}
/**
* @param array<string> $aliased_classes
*/
public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
int $php_major_version,
int $php_minor_version
): ?string {
return $php_major_version >= 7 ? 'float' : null;
}
}

View File

@ -12,4 +12,17 @@ class TInt extends Scalar
{
return 'int';
}
/**
* @param array<string> $aliased_classes
*/
public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
int $php_major_version,
int $php_minor_version
): ?string {
return $php_major_version >= 7 ? 'int' : null;
}
}

View File

@ -3,6 +3,19 @@ namespace Psalm\Type\Atomic;
class TString extends Scalar
{
/**
* @param array<string> $aliased_classes
*/
public function toPhpString(
?string $namespace,
array $aliased_classes,
?string $this_class,
int $php_major_version,
int $php_minor_version
): ?string {
return $php_major_version >= 7 ? 'string' : null;
}
public function __toString(): string
{
return 'string';