mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Add JSON_THROW_ON_ERROR full support
This commit is contained in:
parent
70a024f5e3
commit
d11c7cdb8e
@ -1468,11 +1468,7 @@ function json_decode(string $json, ?bool $associative = null, int $depth = 512,
|
||||
/**
|
||||
* @psalm-pure
|
||||
*
|
||||
* @return (
|
||||
* $flags is 4194304
|
||||
* ? non-empty-string
|
||||
* : ($flags is 4194560 ? non-empty-string : non-empty-string|false)
|
||||
* )
|
||||
* @return ($flags is int<4194304, 8388607> ? non-empty-string : non-empty-string|false)
|
||||
*
|
||||
* @psalm-flow ($value) -> return
|
||||
* @psalm-ignore-falsable-return
|
||||
|
@ -131,5 +131,19 @@ class CoreStubsTest extends TestCase
|
||||
'$a===' => 'non-empty-string',
|
||||
],
|
||||
];
|
||||
yield 'json_encode returns a non-empty-string with JSON_THROW_ON_ERROR' => [
|
||||
'code' => '<?php
|
||||
$a = json_encode([], JSON_THROW_ON_ERROR | JSON_HEX_TAG);
|
||||
$b = json_encode([], JSON_THROW_ON_ERROR | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
|
||||
$c = json_encode([], JSON_THROW_ON_ERROR | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
|
||||
$d = json_encode([], JSON_THROW_ON_ERROR | JSON_PRESERVE_ZERO_FRACTION);
|
||||
',
|
||||
'assertions' => [
|
||||
'$a===' => 'non-empty-string',
|
||||
'$b===' => 'non-empty-string',
|
||||
'$c===' => 'non-empty-string',
|
||||
'$d===' => 'non-empty-string',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user