1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Add stub for json_encode

This commit is contained in:
Brown 2020-04-04 11:18:24 -04:00
parent 4aae4fc631
commit 4b36c4e4bf
3 changed files with 20 additions and 4 deletions

View File

@ -2011,9 +2011,9 @@ class Config
} }
$php_version = $composer_json['require']['php'] ?? null; $php_version = $composer_json['require']['php'] ?? null;
if ($php_version) { if (\is_string($php_version)) {
foreach (['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] as $candidate) { foreach (['5.4', '5.5', '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0'] as $candidate) {
if (Semver::satisfies($candidate, (string)$php_version)) { if (Semver::satisfies($candidate, $php_version)) {
return $candidate; return $candidate;
} }
} }

View File

@ -328,6 +328,20 @@ function sodium_memzero(string &$reference): void
{ {
} }
/**
* @psalm-return (
* $associative is true
* ? null|scalar|array<null|scalar|array<null|scalar|array>>
* : null|scalar|array<int, null|scalar|array<int, null|scalar|array|stdClass>|stdClass>|stdClass
* )
*/
function json_decode(
string $json,
bool $associative = false,
int $depth = 512,
int $options = 0
) {}
/** /**
* @param string|string[] $search * @param string|string[] $search
* @param string|string[] $replace * @param string|string[] $replace

View File

@ -132,8 +132,10 @@ function getVendorDir($current_dir)
exit(1); exit(1);
} }
if (isset($composer_json['config']['vendor-dir'])) { if (isset($composer_json['config']['vendor-dir'])
return (string) $composer_json['config']['vendor-dir']; && is_string($composer_json['config']['vendor-dir'])
) {
return $composer_json['config']['vendor-dir'];
} }
return 'vendor'; return 'vendor';