Skip to content

Commit

Permalink
Update functionMap
Browse files Browse the repository at this point in the history
  • Loading branch information
zonuexe committed Nov 27, 2023
1 parent e031e6f commit c8a7996
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 16 deletions.
20 changes: 10 additions & 10 deletions resources/functionMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -1543,7 +1543,7 @@
'date_default_timezone_set' => ['bool', 'timezone_identifier'=>'string'],
'date_diff' => ['DateInterval', 'obj1'=>'DateTimeInterface', 'obj2'=>'DateTimeInterface', 'absolute='=>'bool'],
'date_format' => ['string', 'obj'=>'DateTimeInterface', 'format'=>'string'],
'date_get_last_errors' => ['array{warning_count: int, warnings: array<int, string>, error_count: int, errors: array<int, string>}|false'],
'date_get_last_errors' => ['array{warning_count: 0|positive-int, warnings: list<string>, error_count: 0|positive-int, errors: list<string>}|false'],
'date_interval_create_from_date_string' => ['DateInterval|false', 'time'=>'string'],
'date_interval_format' => ['string', 'object'=>'DateInterval', 'format'=>'string'],
'date_isodate_set' => ['DateTime|false', 'object'=>'DateTime', 'year'=>'int', 'week'=>'int', 'day='=>'int|mixed'],
Expand Down Expand Up @@ -1601,7 +1601,7 @@
'DateTime::createFromImmutable' => ['static', 'object'=>'DateTimeImmutable'],
'DateTime::diff' => ['DateInterval', 'datetime2'=>'DateTimeInterface', 'absolute='=>'bool'],
'DateTime::format' => ['string', 'format'=>'string'],
'DateTime::getLastErrors' => ['array{warning_count: int, warnings: array<int, string>, error_count: int, errors: array<int, string>}|false'],
'DateTime::getLastErrors' => ['array{warning_count: 0|positive-int, warnings: list<string>, error_count: 0|positive-int, errors: list<string>}|false'],
'DateTime::getOffset' => ['int'],
'DateTime::getTimestamp' => ['int'],
'DateTime::getTimezone' => ['DateTimeZone'],
Expand All @@ -1620,7 +1620,7 @@
'DateTimeImmutable::createFromMutable' => ['static', 'datetime'=>'DateTime'],
'DateTimeImmutable::diff' => ['DateInterval', 'datetime2'=>'DateTimeInterface', 'absolute='=>'bool'],
'DateTimeImmutable::format' => ['string', 'format'=>'string'],
'DateTimeImmutable::getLastErrors' => ['array{warning_count: int, warnings: array<int, string>, error_count: int, errors: array<int, string>}|false'],
'DateTimeImmutable::getLastErrors' => ['array{warning_count: 0|positive-int, warnings: list<string>, error_count: 0|positive-int, errors: list<string>}|false'],
'DateTimeImmutable::getOffset' => ['int'],
'DateTimeImmutable::getTimestamp' => ['int'],
'DateTimeImmutable::getTimezone' => ['DateTimeZone'],
Expand Down Expand Up @@ -2639,7 +2639,7 @@
'explode' => ['list<string>|false', 'separator'=>'string', 'str'=>'string', 'limit='=>'int'],
'expm1' => ['float', 'number'=>'float'],
'extension_loaded' => ['bool', 'extension_name'=>'string'],
'extract' => ['int', '&rw_var_array'=>'array', 'extract_type='=>'int', 'prefix='=>'string|null'],
'extract' => ['0|positive-int', '&rw_var_array'=>'array', 'extract_type='=>'int', 'prefix='=>'string|null'],
'ezmlm_hash' => ['int', 'addr'=>'string'],
'fam_cancel_monitor' => ['bool', 'fam'=>'resource', 'fam_monitor'=>'resource'],
'fam_close' => ['void', 'fam'=>'resource'],
Expand Down Expand Up @@ -2968,7 +2968,7 @@
'filter_id' => ['int|false', 'filtername'=>'string'],
'filter_input' => ['mixed', 'type'=>'int', 'variable_name'=>'string', 'filter='=>'int', 'options='=>'array|int'],
'filter_input_array' => ['array|false|null', 'type'=>'int', 'definition='=>'int|array', 'add_empty='=>'bool'],
'filter_list' => ['array'],
'filter_list' => ['non-empty-list<non-falsy-string>'],
'filter_var' => ['mixed', 'variable'=>'mixed', 'filter='=>'int', 'options='=>'mixed'],
'filter_var_array' => ['array|false|null', 'data'=>'array', 'definition='=>'mixed', 'add_empty='=>'bool'],
'FilterIterator::__construct' => ['void', 'iterator'=>'Iterator'],
Expand Down Expand Up @@ -5700,7 +5700,7 @@
'jpeg2wbmp' => ['bool', 'jpegname'=>'string', 'wbmpname'=>'string', 'dest_height'=>'int', 'dest_width'=>'int', 'threshold'=>'int'],
'json_decode' => ['mixed', 'json'=>'string', 'assoc='=>'bool|null', 'depth='=>'positive-int', 'options='=>'int'],
'json_encode' => ['non-empty-string|false', 'data'=>'mixed', 'options='=>'int', 'depth='=>'positive-int'],
'json_last_error' => ['int'],
'json_last_error' => ['JSON_ERROR_NONE|JSON_ERROR_DEPTH|JSON_ERROR_STATE_MISMATCH|JSON_ERROR_CTRL_CHAR|JSON_ERROR_SYNTAX|JSON_ERROR_UTF8|JSON_ERROR_RECURSION|JSON_ERROR_INF_OR_NAN|JSON_ERROR_UNSUPPORTED_TYPE|JSON_ERROR_INVALID_PROPERTY_NAME|JSON_ERROR_UTF16'],
'json_last_error_msg' => ['string'],
'JsonIncrementalParser::__construct' => ['void', 'depth'=>'', 'options'=>''],
'JsonIncrementalParser::get' => ['', 'options'=>''],
Expand Down Expand Up @@ -8318,10 +8318,10 @@
'openssl_encrypt' => ['string|false', 'data'=>'string', 'method'=>'string', 'key'=>'string', 'options='=>'int', 'iv='=>'string', '&w_tag='=>'string', 'aad='=>'string', 'tag_length='=>'int'],
'openssl_error_string' => ['string|false'],
'openssl_free_key' => ['void', 'key_identifier'=>'resource'],
'openssl_get_cert_locations' => ['array'],
'openssl_get_cipher_methods' => ['array', 'aliases='=>'bool'],
'openssl_get_cert_locations' => ['array<non-falsy-string, string>'],
'openssl_get_cipher_methods' => ['list<string>', 'aliases='=>'bool'],
'openssl_get_curve_names' => ['list<string>|false'],
'openssl_get_md_methods' => ['array', 'aliases='=>'bool'],
'openssl_get_md_methods' => ['list<string>', 'aliases='=>'bool'],
'openssl_get_privatekey' => ['resource|false', 'key'=>'string', 'passphrase='=>'string'],
'openssl_get_publickey' => ['resource|false', 'cert'=>'resource|string'],
'openssl_open' => ['bool', 'sealed_data'=>'string', '&w_open_data'=>'string', 'env_key'=>'string', 'priv_key_id'=>'string|array|resource', 'method='=>'string', 'iv='=>'string'],
Expand Down Expand Up @@ -12017,7 +12017,7 @@
'stream_set_write_buffer' => ['int', 'fp'=>'resource', 'buffer'=>'int'],
'stream_socket_accept' => ['resource|false', 'serverstream'=>'resource', 'timeout='=>'float', '&w_peername='=>'string'],
'stream_socket_client' => ['resource|false', 'remoteaddress'=>'string', '&w_errcode='=>'int', '&w_errstring='=>'string', 'timeout='=>'float', 'flags='=>'int', 'context='=>'resource'],
'stream_socket_enable_crypto' => ['int|bool', 'stream'=>'resource', 'enable'=>'bool', 'cryptokind='=>'int', 'sessionstream='=>'resource'],
'stream_socket_enable_crypto' => ['0|bool', 'stream'=>'resource', 'enable'=>'bool', 'cryptokind='=>'int', 'sessionstream='=>'resource'],
'stream_socket_get_name' => ['string|false', 'stream'=>'resource', 'want_peer'=>'bool'],
'stream_socket_pair' => ['resource[]|false', 'domain'=>'int', 'type'=>'int', 'protocol'=>'int'],
'stream_socket_recvfrom' => ['string|false', 'stream'=>'resource', 'amount'=>'int', 'flags='=>'int', '&w_remote_addr='=>'string'],
Expand Down
3 changes: 2 additions & 1 deletion resources/functionMap_bleedingEdge.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
'ftp_put' => ['bool', 'stream'=>'resource', 'remote_file'=>'string', 'local_file'=>'string', 'mode='=>'FTP_ASCII|FTP_BINARY', 'startpos='=>'int'],
'scandir' => ['list<string>|false', 'dir'=>'string', 'sorting_order='=>'SCANDIR_SORT_ASCENDING|SCANDIR_SORT_DESCENDING| SCANDIR_SORT_NONE', 'context='=>'resource'],
'stream_socket_client' => ['resource|false', 'remoteaddress'=>'string', '&w_errcode='=>'int', '&w_errstring='=>'string', 'timeout='=>'float', 'flags='=>'int-mask<STREAM_CLIENT_CONNECT|STREAM_CLIENT_ASYNC_CONNECT|STREAM_CLIENT_PERSISTENT>', 'context='=>'resource'],
'extract' => ['int', '&rw_var_array'=>'array', 'extract_type='=>'EXTR_OVERWRITE|EXTR_SKIP|EXTR_PREFIX_SAME|EXTR_PREFIX_ALL|EXTR_PREFIX_INVALID|EXTR_IF_EXISTS|EXTR_PREFIX_IF_EXISTS|EXTR_REFS', 'prefix='=>'string|null'],
'stream_socket_enable_crypto' => ['0|bool', 'stream'=>'resource', 'enable'=>'bool', 'crypto_method='=>'STREAM_CRYPTO_METHOD_SSLv2_CLIENT|STREAM_CRYPTO_METHOD_SSLv3_CLIENT|STREAM_CRYPTO_METHOD_SSLv23_CLIENT|STREAM_CRYPTO_METHOD_ANY_CLIENT|STREAM_CRYPTO_METHOD_TLS_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_0_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT|STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT|STREAM_CRYPTO_METHOD_SSLv2_SERVER|STREAM_CRYPTO_METHOD_SSLv3_SERVER|STREAM_CRYPTO_METHOD_SSLv23_SERVER|STREAM_CRYPTO_METHOD_ANY_SERVER|STREAM_CRYPTO_METHOD_TLS_SERVER|STREAM_CRYPTO_METHOD_TLSv1_0_SERVER|STREAM_CRYPTO_METHOD_TLSv1_1_SERVER|STREAM_CRYPTO_METHOD_TLSv1_2_SERVER|STREAM_CRYPTO_METHOD_TLSv1_3_SERVER', 'session_stream='=>'resource'],
'extract' => ['0|positive-int', '&rw_var_array'=>'array', 'extract_type='=>'EXTR_OVERWRITE|EXTR_SKIP|EXTR_PREFIX_SAME|EXTR_PREFIX_ALL|EXTR_PREFIX_INVALID|EXTR_IF_EXISTS|EXTR_PREFIX_IF_EXISTS|EXTR_REFS', 'prefix='=>'string|null'],
],
'old' => [

Expand Down
6 changes: 3 additions & 3 deletions tests/PHPStan/Analyser/data/bug-2863.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use function PHPStan\Testing\assertType;

$result = json_decode('{"a":5}');
assertType('int', json_last_error());
assertType('0|1|2|3|4|5|6|7|8|9|10', json_last_error());
assertType('string', json_last_error_msg());

if (json_last_error() !== JSON_ERROR_NONE || json_last_error_msg() !== 'No error') {
Expand All @@ -17,7 +17,7 @@

//
$result2 = json_decode('');
assertType('int', json_last_error());
assertType('0|1|2|3|4|5|6|7|8|9|10', json_last_error());
assertType('string', json_last_error_msg());

if (json_last_error() !== JSON_ERROR_NONE || json_last_error_msg() !== 'No error') {
Expand All @@ -29,7 +29,7 @@

//
$result3 = json_encode([]);
assertType('int', json_last_error());
assertType('0|1|2|3|4|5|6|7|8|9|10', json_last_error());
assertType('string', json_last_error_msg());

if (json_last_error() !== JSON_ERROR_NONE || json_last_error_msg() !== 'No error') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use PHPStan\Type\Constant\ConstantStringType;
use PHPStan\Type\FileTypeMapper;
use PHPStan\Type\IntegerType;
use PHPStan\Type\IntegerRangeType;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use PHPStan\Type\ObjectType;
Expand Down Expand Up @@ -94,9 +95,9 @@ public function dataFunctions(): array
new ConstantStringType('error_count'),
new ConstantStringType('errors'),
], [
new IntegerType(),
IntegerRangeType::fromInterval(0, null),
new ArrayType(new IntegerType(), new StringType()),
new IntegerType(),
IntegerRangeType::fromInterval(0, null),
new ArrayType(new IntegerType(), new StringType()),
]),
]),
Expand Down

0 comments on commit c8a7996

Please sign in to comment.