Answer the question
In order to leave comments, you need to log in
How to make PhpStorm treat JsonException as throwing json_decode exception?
The point is simple. There is a code, it has this:
try {
$decoded_content = json_decode($content, true, 512, JSON_THROW_ON_ERROR);
} catch (JsonException $e) {
...
}
Answer the question
In order to leave comments, you need to log in
either wait until they fix it, or create your own stub (work for a couple of minutes, you don’t need to fork anything).
create a .phpstorm.meta.php file in the project and put in it
<?php
/**
* (PHP 5 >= 5.2.0, PECL json >= 1.2.0)<br/>
* Returns the JSON representation of a value
*
* @link https://php.net/manual/en/function.json-encode.php
*
* @param mixed $value <p>
* The <i>value</i> being encoded. Can be any type except
* a resource.
* </p>
* <p>
* All string data must be UTF-8 encoded.
* </p>
* <p>PHP implements a superset of
* JSON - it will also encode and decode scalar types and <b>NULL</b>. The JSON standard
* only supports these values when they are nested inside an array or an object.
* </p>
* @param int $options [optional] <p>
* Bitmask consisting of <b>JSON_HEX_QUOT</b>,
* <b>JSON_HEX_TAG</b>,
* <b>JSON_HEX_AMP</b>,
* <b>JSON_HEX_APOS</b>,
* <b>JSON_NUMERIC_CHECK</b>,
* <b>JSON_PRETTY_PRINT</b>,
* <b>JSON_UNESCAPED_SLASHES</b>,
* <b>JSON_FORCE_OBJECT</b>,
* <b>JSON_UNESCAPED_UNICODE</b>.
* <b>JSON_THROW_ON_ERROR</b> The behaviour of these
* constants is described on
* the JSON constants page.
* </p>
* @param int $depth [optional] <p>
* Set the maximum depth. Must be greater than zero.
* </p>
*
* @throws JsonException
* @return string|false a JSON encoded string on success or <b>FALSE</b> on failure.
*/
function json_encode( $value, $options = 0, $depth = 512 ) {}
/**
* (PHP 5 >= 5.2.0, PECL json >= 1.2.0)<br/>
* Decodes a JSON string
*
* @link https://php.net/manual/en/function.json-decode.php
*
* @param string $json <p>
* The <i>json</i> string being decoded.
* </p>
* <p>
* This function only works with UTF-8 encoded strings.
* </p>
* <p>PHP implements a superset of
* JSON - it will also encode and decode scalar types and <b>NULL</b>. The JSON standard
* only supports these values when they are nested inside an array or an object.
* </p>
* @param bool $assoc [optional] <p>
* When <b>TRUE</b>, returned objects will be converted into
* associative arrays.
* </p>
* @param int $depth [optional] <p>
* User specified recursion depth.
* </p>
* @param int $options [optional] <p>
* Bitmask of JSON decode options. Currently only
* <b>JSON_BIGINT_AS_STRING</b>
* is supported (default is to cast large integers as floats)
*
* <b>JSON_THROW_ON_ERROR</b> when passed this flag, the error behaviour of these functions is changed. The global error state is left untouched, and if an error occurs that would otherwise set it, these functions instead throw a JsonException
* </p>
*
* @throws JsonException
* @return mixed the value encoded in <i>json</i> in appropriate
* PHP type. Values true, false and
* null (case-insensitive) are returned as <b>TRUE</b>, <b>FALSE</b>
* and <b>NULL</b> respectively. <b>NULL</b> is returned if the
* <i>json</i> cannot be decoded or if the encoded
* data is deeper than the recursion limit.
*/
function json_decode( $json, $assoc = false, $depth = 512, $options = 0 ) {}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question